HarryCallaghan
Board Regular
- Joined
- Jan 30, 2013
- Messages
- 50
Hello.
I have a table with codes of articles and prices and i need to give the table to some person but he can't know what are the real codes of the articles. For example, if i have an article with the code "R76543H65" i want to "encrypt" to something like "T67R78598" or something like that. I've tried some XOR encrypt functions but what it does is to encrypt with weird chars and i dont want the person who i have to give the table to know that the codes arent real, i dont know if i'm explaining that well. I have like 14K articles.
That's the XOR function i have tried:
I have a table with codes of articles and prices and i need to give the table to some person but he can't know what are the real codes of the articles. For example, if i have an article with the code "R76543H65" i want to "encrypt" to something like "T67R78598" or something like that. I've tried some XOR encrypt functions but what it does is to encrypt with weird chars and i dont want the person who i have to give the table to know that the codes arent real, i dont know if i'm explaining that well. I have like 14K articles.
That's the XOR function i have tried:
Code:
Function XorC(ByVal sData As String, ByVal sKey As String) As String
Dim l As Long, i As Long, byIn() As Byte, byOut() As Byte, byKey() As Byte
Dim bEncOrDec As Boolean
'confirm valid string and key input:
If Len(sData) = 0 Or Len(sKey) = 0 Then XorC = "Invalid argument(s) used": Exit Function
'check whether running encryption or decryption (flagged by presence of "xxx" at start of sData):
If Left$(sData, 3) = "xxx" Then
bEncOrDec = False 'decryption
sData = Mid$(sData, 4)
Else
bEncOrDec = True 'encryption
End If
'assign strings to byte arrays (unicode)
byIn = sData
byOut = sData
byKey = sKey
l = LBound(byKey)
For i = LBound(byIn) To UBound(byIn) - 1 Step 2
byOut(i) = ((byIn(i) + Not bEncOrDec) Xor byKey(l)) - bEncOrDec 'avoid Chr$(0) by using bEncOrDec flag
l = l + 2
If l > UBound(byKey) Then l = LBound(byKey) 'ensure stay within bounds of Key
Next i
XorC = byOut
If bEncOrDec Then XorC = "xxx" & XorC 'add "xxx" onto encrypted text
End Function