Jump to content

Need to decrypt an encryption in PHP


nuttycoder

Recommended Posts

Hi on my forum one of my members has created an encryption algorithm and would like to know to decrypt it, I don't understand how it work's let alone decrypt it so I was hoping someone on here might know.

 

Here's there post:

 

I've made the following encryption algorithm, but I need to decrypt it using PHP. Please could someone help me decrypt it.

 

    Public Function EncryptName(ByValue $EName As String) As String
    Declare $Temp As String, $Temp2, $Temp3 As Byte, $Temp4, $Temp5
    For i = 1 To Length($EName)
      $Temp = $Temp & CharacterFromASCII(122 - Value(Mid($EName, i, 1)))
    Next i
    For i = 1 To Length($Temp)
      $Temp3 = ASCIIFromCharacter(Mid($Temp, i, 1))
      If ($Temp3 >= 128) Then
       $Temp2 = $Temp2 & "1"
       $Temp3 = $Temp3 - 128
      Else
       $Temp2 = $Temp2 & "0"
      End If
      $Temp2 = $Temp2 & Round(Rnd)
      If ($Temp3 >= 64) Then
       $Temp2 = $Temp2 & "1"
       $Temp3 = $Temp3 - 64
      Else
       $Temp2 = $Temp2 & "0"
      End If
      $Temp2 = $Temp2 & Round(Rnd)
      If ($Temp3 >= 32) Then
       $Temp2 = $Temp2 & "1"
       $Temp3 = $Temp3 - 32
      Else
       $Temp2 = $Temp2 & "0"
      End If
      $Temp2 = $Temp2 & Round(Rnd)
      If ($Temp3 >= 16) Then
       $Temp2 = $Temp2 & "1"
       $Temp3 = $Temp3 - 16
      Else
       $Temp2 = $Temp2 & "0"
      End If
      $Temp2 = $Temp2 & Round(Rnd)
      If ($Temp3 >=  Then
       $Temp2 = $Temp2 & "1"
       $Temp3 = $Temp3 - 8
      Else
      $Temp2 = $Temp2 & "0"
      End If
      $Temp2 = $Temp2 & Round(Rnd)
      If ($Temp3 >= 4) Then
       $Temp2 = $Temp2 & "1"
       $Temp3 = $Temp3 - 4
      Else
      $Temp2 = $Temp2 & "0"
      End If
      $Temp2 = $Temp2 & Round(Rnd)
      If ($Temp3 >= 2) Then
       $Temp2 = $Temp2 & "1"
       $Temp3 = $Temp3 - 2
      Else
      $Temp2 = $Temp2 & "0"
      End If
      $Temp2 = $Temp2 & Round(Rnd)
      If ($Temp3 >= 1) Then
       $Temp2 = $Temp2 & "1"
       $Temp3 = $Temp3 - 1
      Else
      $Temp2 = $Temp2 & "0"
      End If
      $Temp2 = $Temp2 & Round(Rnd)
    Next i
    For i = 1 To Length($Temp2) / 4
      $Temp4 = 0
      If (Mid($Temp2, i * 4 - 3, 1)) Then $Temp4 = $Temp4 + 8
      If (Mid($Temp2, i * 4 - 2, 1)) Then $Temp4 = $Temp4 + 4
      If (Mid($Temp2, i * 4 - 1, 1)) Then $Temp4 = $Temp4 + 2
      If (Mid($Temp2, i * 4 - 0, 1)) Then $Temp4 = $Temp4 + 1
      $Temp5 = $Temp5 & Hex($Temp4)
    Next i
    EncryptName = $Temp5
    End Function

 

 

Mid(String, Start, Length) returns the section of the string starting from the Start character and contains the next Length characters. First character is position 1.

Example:

Mid("Hello", 2, 3) will return "ell"

 

Round(Number) will round Number to the nearest integer.

 

Rnd will return a random number between 0 and 1.

 

thanks.

Link to comment
Share on other sites

Hi on my forum one of my members has created an encryption algorithm and would like to know to decrypt it, I don't understand how it work's let alone decrypt it so I was hoping someone on here might know.

 

Here's there post:

 

I've made the following encryption algorithm, but I need to decrypt it using PHP. Please could someone help me decrypt it.

 

    Public Function EncryptName(ByValue $EName As String) As String
    Declare $Temp As String, $Temp2, $Temp3 As Byte, $Temp4, $Temp5
    For i = 1 To Length($EName)
      $Temp = $Temp & CharacterFromASCII(122 - Value(Mid($EName, i, 1)))
    Next i
    For i = 1 To Length($Temp)
      $Temp3 = ASCIIFromCharacter(Mid($Temp, i, 1))
      If ($Temp3 >= 128) Then
       $Temp2 = $Temp2 & "1"
       $Temp3 = $Temp3 - 128
      Else
       $Temp2 = $Temp2 & "0"
      End If
      $Temp2 = $Temp2 & Round(Rnd)
      If ($Temp3 >= 64) Then
       $Temp2 = $Temp2 & "1"
       $Temp3 = $Temp3 - 64
      Else
       $Temp2 = $Temp2 & "0"
      End If
      $Temp2 = $Temp2 & Round(Rnd)
      If ($Temp3 >= 32) Then
       $Temp2 = $Temp2 & "1"
       $Temp3 = $Temp3 - 32
      Else
       $Temp2 = $Temp2 & "0"
      End If
      $Temp2 = $Temp2 & Round(Rnd)
      If ($Temp3 >= 16) Then
       $Temp2 = $Temp2 & "1"
       $Temp3 = $Temp3 - 16
      Else
       $Temp2 = $Temp2 & "0"
      End If
      $Temp2 = $Temp2 & Round(Rnd)
      If ($Temp3 >=  Then
       $Temp2 = $Temp2 & "1"
       $Temp3 = $Temp3 - 8
      Else
      $Temp2 = $Temp2 & "0"
      End If
      $Temp2 = $Temp2 & Round(Rnd)
      If ($Temp3 >= 4) Then
       $Temp2 = $Temp2 & "1"
       $Temp3 = $Temp3 - 4
      Else
      $Temp2 = $Temp2 & "0"
      End If
      $Temp2 = $Temp2 & Round(Rnd)
      If ($Temp3 >= 2) Then
       $Temp2 = $Temp2 & "1"
       $Temp3 = $Temp3 - 2
      Else
      $Temp2 = $Temp2 & "0"
      End If
      $Temp2 = $Temp2 & Round(Rnd)
      If ($Temp3 >= 1) Then
       $Temp2 = $Temp2 & "1"
       $Temp3 = $Temp3 - 1
      Else
      $Temp2 = $Temp2 & "0"
      End If
      $Temp2 = $Temp2 & Round(Rnd)
    Next i
    For i = 1 To Length($Temp2) / 4
      $Temp4 = 0
      If (Mid($Temp2, i * 4 - 3, 1)) Then $Temp4 = $Temp4 + 8
      If (Mid($Temp2, i * 4 - 2, 1)) Then $Temp4 = $Temp4 + 4
      If (Mid($Temp2, i * 4 - 1, 1)) Then $Temp4 = $Temp4 + 2
      If (Mid($Temp2, i * 4 - 0, 1)) Then $Temp4 = $Temp4 + 1
      $Temp5 = $Temp5 & Hex($Temp4)
    Next i
    EncryptName = $Temp5
    End Function

 

 

Mid(String, Start, Length) returns the section of the string starting from the Start character and contains the next Length characters. First character is position 1.

Example:

Mid("Hello", 2, 3) will return "ell"

 

Round(Number) will round Number to the nearest integer.

 

Rnd will return a random number between 0 and 1.

 

thanks.

 

doesn't seem to be wrote in php. or if it was it would throw out a ton of errors :D

Link to comment
Share on other sites

just did a quick search for CharacterFromASCII and according to my first two pages of results it doesn't appear to be a standard function in any language? custom function maybe or the rest is basic maths and could only presume the function CharacterFromASCII just returns the ASCII for each letter in the encoded word, you would have to work back the maths though the round is a problem as you will never know what it has been rounded up from. and for a decoder to work it would need to store the amount rounded up by somewhere.

 

Also if it adds random things to the string it must store what's been added somewhere or you could never decode it.

Link to comment
Share on other sites

This is what the user said about it:

 

It's pseudocode. I put the $ in to help show what were variables.

 

I don't know what pseudocode code is lol thought it was worth a try.

 

thanks anyway.

 

pseudocode is like half-English half-code language. Usually people write that so they can get their ideas out before actually writing the entire code.

Link to comment
Share on other sites

The code is pointless, its not encryption, if you read the logic your notice that.

 

Temp = will loss any character with an ASCII value over 122, ie "{}~€"

Temp2 = I love this one, it doesn't even use ANY related data to the anything used so far, its total random!

Temp3 = adds and removed from the new values from temp, but that's it temp 3 isn't ever used!

-Okay So far only Temp and Temp3 has ANY thing related to the data to be "encrypted"-

Temp4 = use temp2 reverses the order in sets of four and added (8,4,2,1)

Temp5 = the hex value from 4 concatenated as one string

 

So the end result is built from Temp4 that's built from Temp2 that's totally random!

 

EDIT: I'll like it if someone else could check my findings as well.

Link to comment
Share on other sites

It's pseudocode. Read it like English, not a programming language. It is describing what it does to the string. I want to use PHP to reverse that.

I'd suggest first learning and writing the actual function in PHP but to me it also doesn't look like it does much of anything other than to string some random things together.  From there you will be able to then get a better idea as to how everything is put together and then reverse it.  I could do it for a fee, or check in php freelance forum for paid assistance but no one here is going to write the entire thing for you in php (decrypt OR encrypt).

 

Here is a rough start for you...

<?php

function EncryptName(ByValue $EName)
{
//what is "ByValue" is that a variable or a constant?
$Temp = NULL;

//loop through all of the individual characters of the string
for ($i=0; $i < strlen($EName); $i++)
{
	$Temp = $Temp.$Temp[$i];
	//I'm not sure what "CharacterFromASCII) does nor "Value()"
	//ok I'll stop there!!  good luck with the rest.
}

/*
    For i = 1 To Length($Temp)
      $Temp3 = ASCIIFromCharacter(Mid($Temp, i, 1))
      If ($Temp3 >= 128) Then
       $Temp2 = $Temp2 & "1"
       $Temp3 = $Temp3 - 128
      Else
       $Temp2 = $Temp2 & "0"
      End If
      $Temp2 = $Temp2 & Round(Rnd)
      If ($Temp3 >= 64) Then
       $Temp2 = $Temp2 & "1"
       $Temp3 = $Temp3 - 64
      Else
       $Temp2 = $Temp2 & "0"
      End If
      $Temp2 = $Temp2 & Round(Rnd)
      If ($Temp3 >= 32) Then
       $Temp2 = $Temp2 & "1"
       $Temp3 = $Temp3 - 32
      Else
       $Temp2 = $Temp2 & "0"
      End If
      $Temp2 = $Temp2 & Round(Rnd)
      If ($Temp3 >= 16) Then
       $Temp2 = $Temp2 & "1"
       $Temp3 = $Temp3 - 16
      Else
       $Temp2 = $Temp2 & "0"
      End If
      $Temp2 = $Temp2 & Round(Rnd)
      If ($Temp3 >=  Then
       $Temp2 = $Temp2 & "1"
       $Temp3 = $Temp3 - 8
      Else
      $Temp2 = $Temp2 & "0"
      End If
      $Temp2 = $Temp2 & Round(Rnd)
      If ($Temp3 >= 4) Then
       $Temp2 = $Temp2 & "1"
       $Temp3 = $Temp3 - 4
      Else
      $Temp2 = $Temp2 & "0"
      End If
      $Temp2 = $Temp2 & Round(Rnd)
      If ($Temp3 >= 2) Then
       $Temp2 = $Temp2 & "1"
       $Temp3 = $Temp3 - 2
      Else
      $Temp2 = $Temp2 & "0"
      End If
      $Temp2 = $Temp2 & Round(Rnd)
      If ($Temp3 >= 1) Then
       $Temp2 = $Temp2 & "1"
       $Temp3 = $Temp3 - 1
      Else
      $Temp2 = $Temp2 & "0"
      End If
      $Temp2 = $Temp2 & Round(Rnd)
    Next i
    For i = 1 To Length($Temp2) / 4
      $Temp4 = 0
      If (Mid($Temp2, i * 4 - 3, 1)) Then $Temp4 = $Temp4 + 8
      If (Mid($Temp2, i * 4 - 2, 1)) Then $Temp4 = $Temp4 + 4
      If (Mid($Temp2, i * 4 - 1, 1)) Then $Temp4 = $Temp4 + 2
      If (Mid($Temp2, i * 4 - 0, 1)) Then $Temp4 = $Temp4 + 1
      $Temp5 = $Temp5 & Hex($Temp4)
    Next i
    EncryptName = $Temp5
    End Function
*/

}
?>

 

That will get you off to a start.  Try just going through line by line.  Again it's hard for anyone to even tell what it does cause it is not even written in php but to me it doesn't look like anything special.  I think it's one of those things that people try to over-write and they think is ultra secure but that's not necessarily the case.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.