Solved

VBScript - encrypt a password based off computer name

Posted on 2006-07-24
2
2,093 Views
Last Modified: 2012-05-05
I've tried using some of the posted encryption functions on here, but can't seem to get them to do what I'm looking for exactly.

I'm looking for a VBScript that I can run via GPO or some other means that will set the local Administrator password. I am fine with the part of the script that will set the password, all I need is an encryption function that I can pass 2 variables: the local computer name, and a static string. The function needs to take those 2 strings and create a cryptic password. On any given computer, since the computer name will not change and neither will the string, the function will return the same password every time, unless the computer name changes. This will make sure each machine has a unique password.

The funtion I'm using now works, but generates a lot of different ASCII characters, so most of them can't be typed out easily on the keyboard.

Does anyone out there have any basic fucntions that might help me out.

Thanks
0
Comment
Question by:AGCIT
2 Comments
 
LVL 13

Expert Comment

by:jmundsack
ID: 17168523
You could encode the computer name and static string using Base64, which consists of only printable characters.

Check out these links:

Encode to Base64:
http://www.motobit.com/tips/detpg_Base64Encode/

Decode from Base64:
http://www.motobit.com/tips/detpg_Base64/

HTH-Jon
0
 
LVL 13

Accepted Solution

by:
Mark_FreeSoftware earned 500 total points
ID: 17169331

try this:

option explicit

MsgBox (encodeString("My Computer", "static string"))



Function encodeString(str1 , str2 )
Const cStrA = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
Dim StrB,tmpStr,n,j
    StrB = "0987654321QWERTYUIOPLKJHGFDSAZXCVBNMmnbvcxzasdfghjklpoiuytrewq"
   tmpStr = str1 & str2
   encodeString = ""
For n = 1 To Len(tmpStr) - 1
   j = InStr(cStrA, Mid(tmpStr, n, 1))
   If j > 0 Then
      encodeString = encodeString & Mid(StrB, j, 1)
      StrB = Right(StrB, Len(StrB) - 1) & Left(StrB, 1)
   End If
Next
End Function
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now