Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
VB
function encode(tmpMessage)

   Dim alpha,crypt,encMessage,x,i

   encMessage=""
     alpha="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ `1234567890-=][;.,~!@#$%^&*()_+|}{"":?><"
     crypt="`=-][;.,~!@#$%^&*()_+|}{"":?><1092837456qazwsxedcrfvtgbyhnujmikolpQAZWSXED CRFVTGBYHNUJMIKOLP"

     for x = 1 to len(tmpMessage)
         for i = 1 to len(alpha)
           if mid(tmpMessage,x,1)=mid(alpha,i,1) then
            encMessage=encMessage+mid(crypt,i,1)
            exit for
           elseif i>=len(alpha) then
            encMessage=encMessage+mid(tmpMessage,x,1)
           end if
         next
         encode = encMessage
     next

End function
Posted
Comments
OriginalGriff 6-Apr-15 4:42am    
And?
What help do you need?

1 solution

This is a simple substitution cypher [not real encryption!] which will be cracked in less than 10 minutes...
Having said that. Here's the incomplete JS code:

for (x = 1; x < tmpMessage.length; x++) { //for each char input text
for (i = 1; i < alpha.length; i++) {
if substring(tmpMessage, x, 1) = substring(alpha, i, 1) {
encMessage = encMessage + substring(crypt, i, 1) //replace the char with the corresponding crypt char
}
}
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900