---
sourceDocument: Australia Platform security
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/de-DE/platform-security

 Release :

    - australia

ft:locale :

    - de-DE

ft:publication_title :

    - Australia Platform security

ft:clusterId :

    - psec

bundleId :

    - psec

workflow :

    - Platform


---

# Sample C

# Sample C {#ariaid-title1}

* Freigeben Version: Australia
* 
* Aktualisiert 12. März 2026
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 Minute Lesedauer

This C class illustrates creating a digest token from three input
parameters.  
* strEncryptionMethod -- lists the hash computation method (SHA1, SHA256 or MD5)
* message -- lists the value to be converted into a digest token
* sharedKey -- lists the secret key
{#c_SampleC__ul_uwx_jyg_y4}  
Hinweis:  
Use stronger secure hash algorithm like SHA256 for digest token generation.  
This sample assumes:

* The web server supports C
* Other code calls this class and passes the expected parameters
{#c_SampleC__ul_fth_4yg_y4}

## Sample Code

      private stringdigestData(string strEncryptionMethod , string message , string sharedKey ) {
                UnicodeEncoding myUnicodeEncoding  = new UnicodeEncoding ( ) ;
     
                byte [ ] messageBytes  = System. Text. Encoding. ASCII. GetBytes (message ) ;
                byte [ ] sharedKeyBytes  = System. Text. Encoding. ASCII. GetBytes (sharedKey ) ;
                byte [ ] hashedMessage ;
     
                string b64SHA1Message ;
     
                 if (this. DEBUG ) {
                    TextBoxMessage. Text = message ;
                    TextBoxSecret. Text = sharedKey ; }
     
                 switch ( (strEncryptionMethod ) )
     
                 { case "SHA1" :
     
                        HMACSHA1 hmacsha1  = new HMACSHA1 ( ) ;
                        hmacsha1. Key = sharedKeyBytes ;
                        hashedMessage  = hmacsha1. ComputeHash (messageBytes ) ;
                        b64SHA1Message  = Convert. ToBase64String (hashedMessage ) ; if (this. DEBUG ) TextBoxDigest. Text = Convert. ToString (hashedMessage ) ; break ;
     
                     case "MD5" :
     
                        HMACMD5 hmacmd5  = new HMACMD5 (sharedKeyBytes ) ;
                        hashedMessage  = hmacmd5. ComputeHash (messageBytes ) ;
                        b64SHA1Message  = Convert. ToBase64String (hashedMessage ) ; if (this. DEBUG ) TextBoxDigest. Text = Convert. ToString (hashedMessage ) ; break ;
     
                     default :
     
                        b64SHA1Message  = "Unknown Encryption Method" ; break ;
     
                 }
     
     
                TextBoxBase64. Text = b64SHA1Message ; return b64SHA1Message ;
     
             }


