2024-11-21

Navigation

Skip Navigation Links

Hash algorithms

Asymmetric Algorithms

Symmetric Cipher Algorithms

Encoding Algorithms

Compression Algorithms

Pseudo Random Number Algorithms

Steganography

Library Wrappers

String Comparison

Others

Syntax highlighting by Prism
PBCrypto.com Mirror

String Permutation

Algorithm creator(s)

n/a


PB author(s)

Michael Mattias


Description

Randomly permutates a string. For example, test might become stet, or etts, etc.


Note

n/a


Source

n/a


See also

n/a


Source Code

Download source code file permutation.bas (Right-click -> "Save as ...")

#COMPILE EXE
 
TYPE SortKeyType
  RandomNo AS LONG
  Index AS LONG
END TYPE
 
FUNCTION RandomStringPermutation (X AS STRING) AS STRING
 LOCAL I AS LONG, StrLen AS LONG, W AS STRING
 StrLen = LEN(X)
 REDIM C(StrLen) AS SortKeyType
 RANDOMIZE TIMER
 FOR I = 1 TO StrLen
   C(I).RandomNo = RND (1, StrLen)
   C(I).Index    = I
 NEXT
 ARRAY SORT C(1)    ' will sort on whole record, which is random
 W = SPACE$(StrLen)
 FOR I = 1 TO STRLEN
  MID$(W, I, 1) = MID$(X, C(I).Index,1)
 NEXT
 FUNCTION = W
END FUNCTION
 
FUNCTION PBMAIN() AS LONG
 MSGBOX RandomStringPermutation("test")
END FUNCTION   

Mirror provided by Knuth Konrad