Solved

VBScript - encrypt a password based off computer name

Posted on 2006-07-24
2
2,096 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

930 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

16 Experts available now in Live!

Get 1:1 Help Now