<-- Previous || Up || Next -->

Caesar Cipher Test Sub
Codes Ciphers Class

Private Sub CaesarCipherTest()
    ' Test of the CaesarCipher function.

    Dim vIgnRtn As Variant
    vIgnRtn = TrueEveryNSeconds(0)

    Dim lngTrial As Long
    For lngTrial = 1 To 10000
        Dim intOffset As Integer
        Dim strPlain As String
        Dim strCipher As String
        
        intOffset = RandomIntegerWithinRange(-255, 255)
        strPlain = RandomString(0, 64, EveryCharacter)
        strCipher = CaesarCipher(strPlain, intOffset, Null)

        If StrComp(CaesarCipher(strCipher, -intOffset, Null), strPlain, vbBinaryCompare) <> 0 Then
            Debug.Print "Error: Trial #" & lngTrial
            Debug.Print " Offset: " & IllustrateValue(intOffset);
            Debug.Print " Plain: " & IllustrateValue(strPlain);
            Debug.Print " Cipher: " & IllustrateValue(strCipher);
            Debug.Print
            Stop
        End If

        If TrueEveryNSeconds(est.TestInterval) Then
            Exit For
        End If
    Next lngTrial
End Sub

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.