Solved

VBScript - encrypt a password based off computer name

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to set the sa password in a vb6 code for sql connection 9 59
Added a column screws up code 5 63
Problem to With line 4 63
Error with a code discussed on this page 5 29
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

809 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