developer:soap-1.2:objects:uehash

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
developer:soap-1.2:objects:uehash [2010/02/12 10:39]
hmcgowan created
developer:soap-1.2:objects:uehash [2010/10/20 15:21]
irina
Line 23: Line 23:
  
 ===== Examples ===== ===== Examples =====
 +==== .NET VB ====
 +<code vb>
 +Dim hash As usaepay.ueHash = New usaepay.ueHash
 +Dim sourcekey As String
 +  Dim pin As String
 + 
 +  ' The source key and pin are created by the merchant ​
 +  sourcekey = "​e42SYc86C4uvlvyP62ow54Kv93SZsJVm"​
 +  pin = "​1234"​
 + 
 +  token = New usaepay.ueSecurityToken
 +  token.SourceKey = sourcekey
 + 
 +  ' To create the hash we must concat the sourcekey, seed and pin
 +  Dim rand As System.Random = New System.Random
 +  hash.Seed = Date.Now.ToUniversalTime & rand.Next()
 + 
 +  Dim prehashvalue As String
 +  prehashvalue = sourcekey & hash.Seed & pin
 + 
 +  ' Generate the md5 hash
 +  hash.Type = "​md5"​
 +  hash.HashValue = GenerateHash(prehashvalue)
 +  token.PinHash = hash
 + 
 +Private Function GenerateHash(ByVal SourceText As String) As String
 +  '​Instantiate an MD5 Provider object
 +  Dim md5 As New MD5CryptoServiceProvider
 + 
 +  '​Compute the hash value from the source
 +  Dim ByteHash() As Byte = md5.ComputeHash(Encoding.Default.GetBytes(SourceText))
 + 
 +  '​Instantiate a StringBuilder object
 +  Dim sb As New StringBuilder
 + 
 +  '​Repack binary hash as hex
 +  For c As Integer = 0 To ByteHash.Length - 1
 +    sb.AppendFormat("​{0:​x2}",​ ByteHash(c))
 +  Next c
 + 
 +  '​Return the hex hash
 +  Return sb.ToString
 +End Function
  
 +
 +</​code>​
 +
 +==== .NET C# ====
 +<code c>
 +usaepay.ueHash hash = new usaepay.ueHash();​
 +            hash.Type = "​md5"; ​ // Type of encryption ​
 +            hash.Seed = Guid.NewGuid().ToString(); ​ // unique encryption seed
 +
 +            // Assemble string and hash
 +            string prehashvalue = string.Concat(token.SourceKey,​ hash.Seed, pin);
 +            hash.HashValue = GenerateHash(prehashvalue);​
 +
 +            // Add hash to token
 +            token.PinHash = hash;
 +</​code>​
developer/soap-1.2/objects/uehash.txt ยท Last modified: 2010/10/20 15:21 by irina

Page Tools