Examples of one line code in different languages ​​for MD5

I am looking for examples of one string code in different languages ​​to get a valid MD5 result (as a string, not a byte or whatever you have). For instance:

PHP: $ token = md5 ($ var1. $ Var2);

I found that VB is especially troublesome to do on a single line.

+3
source share
7 answers

WITH#:

string hash = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(input, "md5");

VB is pretty much the same.

Here it does not use the System.Web namespace:

string hash = Convert.ToBase64String(new System.Security.Cryptography.MD5CryptoServiceProvider().ComputeHash(System.Text.Encoding.UTF8.GetBytes(input)));

Or in readable form:

string hash =
     Convert.ToBase64String
     (new System.Security.Cryptography.MD5CryptoServiceProvider()
          .ComputeHash
              (System.Text.Encoding.UTF8.GetBytes
                  (input)
              )
     );
+2
source

Python

token = __import__('md5').new(var1 + var2).hexdigest()

or, if md5imported using alvadism:

token = md5.new(var1 + var2).hexdigest()

Thanks to Greg Huguill

+2
source

- , . , md5_in_one_line ( Md5InOneLine) , .

, , Md5InOneLine #, , .

+2

: " MD5?" , , , , . !

+1

VBScript: MD5 webdevbros, :

hash = (new MD5).hash("some value")
+1

, MD5 . , VB 1 , . , MD5 VB , .

If all this in 1 line of code is very important, here is 1 line of VB. which does not use the System.Web namespace.

Dim MD5 As New System.Security.Cryptography.MD5CryptoServiceProvider() : Dim HashBytes() As Byte : Dim MD5Str As String = "" : HashBytes = MD5.ComputeHash(System.Text.Encoding.UTF8.GetBytes("MyString")) : For i As Integer = 0 To HashBytes.Length - 1 : MD5Str &= HashBytes(i).ToString("x").PadLeft(2, "0") : Next

This will be the "MyString" hash and save the MD5 sum to MD5Str.

0
source

Coldfusion has many hash algorithms, MD5 by default.

cfset var md5hashresult = hash ("string to hash")

0
source

Source: https://habr.com/ru/post/1699089/


All Articles