Solved

VBScript - encrypt a password based off computer name

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
passing parameter in sql procedure 9 61
Advice in Xamarin 21 78
Excel Automation VBA 19 68
Sub or Function is not defined 6 26
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no 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…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

776 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