Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.
Public Function getchecksum(sstring As String) As String
Dim I As Integer
Dim chk As Long
Dim n1, n2, n3, n4, n5, n6, n7, n8 As Byte
chk = 0
For I = 1 To Len(sstring)
chk = chk * 2
' Set bit 0 to whatever bit 16 is..
If (chk And 65536) = 0 Then
' Bit 16 is clear, so clear bit 0
chk = chk And 65534
Else
' Bit 16 is set, so set bit 0
chk = chk Or 1
End If
' Clear bit 16..
chk = chk And 65535
' XOR sum
chk = chk Xor Asc(Mid$(buf, I, 1))
Next I
n8 = chk And 15
chk = Int(chk / 4)
n7 = chk And 15
chk = Int(chk / 4)
n6 = chk And 15
chk = Int(chk / 4)
n5 = chk And 15
chk = Int(chk / 4)
n4 = chk And 15
chk = Int(chk / 4)
n3 = chk And 15
chk = Int(chk / 4)
n2 = chk And 15
chk = Int(chk / 4)
n1 = chk And 15
' Add 48 to each one (ascii '0')
n1 = n1 + 48
If n1 > 57 Then
n1 = 65 + (n1 - 57)
End If
n2 = n2 + 48
If n2 > 57 Then
n2 = 65 + (n2 - 57)
End If
n3 = n3 + 48
If n3 > 57 Then
n3 = 65 + (n3 - 57)
End If
n4 = n4 + 48
If n4 > 57 Then
n4 = 65 + (n4 - 57)
End If
n5 = n5 + 48
If n5 > 57 Then
n5 = 65 + (n5 - 57)
End If
n6 = n6 + 48
If n6 > 57 Then
n6 = 65 + (n6 - 57)
End If
n7 = n7 + 48
If n7 > 57 Then
n7 = 65 + (n7 - 57)
End If
n8 = n8 + 48
If n8 > 57 Then
n8 = 65 + (n8 - 57)
End If
getchecksum = Chr$(n1) + Chr$(n2) + Chr$(n3) + Chr$(n4) + Chr$(n5) + Chr$(n6) + Chr$(n7) + Chr$(n8)
End Function
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
<?php
function getchecksum($sstring){
$chk = 0;
for ($I=1; strlen($sstring); $I++){
$chk = $chk * 2;
// Set bit 0 to whatever bit 16 is..
If (($chk And 65536) === 0 ){
// Bit 16 is clear, so clear bit 0
$chk = ( $chk And 65534 );
} else {
// Bit 16 is set, so set bit 0
$chk = ($chk Or 1);
}
// Clear bit 16..
$chk = ($chk And 65535);
// XOR sum
$chk = ($chk ^ Ord(substr($buf, $I, 1)));
}
$n8 = ($chk And 15);
$chk = intval($chk / 4);
$n7 = ($chk And 15);
$chk = intval($chk / 4)
$n6 = ($chk And 15);
$chk = intval($chk / 4)
$n5 = ($chk And 15);
$chk = intval($chk / 4)
$n4 = ($chk And 15);
$chk = intval($chk / 4)
$n3 = ($chk And 15);
$chk = intval($chk / 4)
$n2 = ($chk And 15);
$chk = intval($chk / 4)
$n1 = ($chk And 15);
// Add 48 to each one (ascii '0')
$n1 = $n1 + 48;
If ( $n1 > 57 ){
$n1 = 65 + ($n1 - 57);
}
$n2 = $n2 + 48;
If ( $n2 > 57 ){
$n2 = 65 + ($n2 - 57);
}
$n3 = $n3 + 48;
If ( $n3 > 57 ){
$n3 = 65 + ($n3 - 57);
}
$n4 = $n4 + 48;
If ($n4 > 57){
$n4 = 65 + ($n4 - 57);
}
$n5 = $n5 + 48;
If ($n5 > 57){
$n5 = 65 + ($n5 - 57);
}
$n6 = $n6 + 48;
If ($n6 > 57){
$n6 = 65 + ($n6 - 57);
}
$n7 = $n7 + 48;
If ($n7 > 57){
$n7 = 65 + ($n7 - 57);
}
$n8 = $n8 + 48;
If ($n8 > 57 ){
$n8 = 65 + ($n8 - 57);
}
return chr($n1).chr($n2).chr($n3).chr($n4).chr($n5).chr($n6).chr($n7).chr($n8);
}
?>
function getchecksum($sstring){
$chk = 0;
$len = strlen($sstring);
for ($I=1; $I<=$len; $I++){
$chk = $chk * 2;
// Set bit 0 to whatever bit 16 is..
If (($chk & 65536) == 0 ){
// Bit 16 is clear, so clear bit 0
$chk = ($chk & 65534);
} else {
// Bit 16 is set, so set bit 0
$chk = ($chk | 1);
}
// Clear bit 16..
$chk = ($chk & 65535);
// XOR sum
$chk = ($chk ^ Ord(substr($sstring, $I-1, 1)));
}
$n8 = ($chk & 15);
$chk = intval($chk / 4);
$n7 = ($chk & 15);
$chk = intval($chk / 4);
$n6 = ($chk & 15);
$chk = intval($chk / 4);
$n5 = ($chk & 15);
$chk = intval($chk / 4);
$n4 = ($chk & 15);
$chk = intval($chk / 4);
$n3 = ($chk & 15);
$chk = intval($chk / 4);
$n2 = ($chk & 15);
$chk = intval($chk / 4);
$n1 = ($chk & 15);
// Add 48 to each one (ascii '0')
$n1 = $n1 + 48;
If ( $n1 > 57 ){
$n1 = 65 + ($n1 - 57);
}
$n2 = $n2 + 48;
If ( $n2 > 57 ){
$n2 = 65 + ($n2 - 57);
}
$n3 = $n3 + 48;
If ( $n3 > 57 ){
$n3 = 65 + ($n3 - 57);
}
$n4 = $n4 + 48;
If ($n4 > 57){
$n4 = 65 + ($n4 - 57);
}
$n5 = $n5 + 48;
If ($n5 > 57){
$n5 = 65 + ($n5 - 57);
}
$n6 = $n6 + 48;
If ($n6 > 57){
$n6 = 65 + ($n6 - 57);
}
$n7 = $n7 + 48;
If ($n7 > 57){
$n7 = 65 + ($n7 - 57);
}
$n8 = $n8 + 48;
If ($n8 > 57 ){
$n8 = 65 + ($n8 - 57);
}
return chr($n1).chr($n2).chr($n3).chr($n4).chr($n5).chr($n6).chr($n7).chr($n8);
}
If you are experiencing a similar issue, please ask a related question
Title | # Comments | Views | Activity |
---|---|---|---|
Add Logo to Bookmark and Tab Headings in Browser | 3 | 32 | |
$_GET call between URL | 3 | 43 | |
Difference between PHPClasse.php and SimplXLS.php | 5 | 24 | |
how can I close a php page to user visits, but allow the page request to form posts? | 5 | 24 |
Join the community of 500,000 technology professionals and ask your questions.