Check OSS data transmission integrity by using 64-bit CRC / Python
up vote
0
down vote
favorite
Currently, OSS can return the 64-bit CRC value for an object uploaded in any mode on Alibaba Cloud OSS. To check the data integrity, I can compare the 64-bit CRC value with the locally calculated value.
Below is a Python code which shows how to check data transmission integrity based on the 64-bit CRC value.
import oss2
from oss2.models import PartInfo
import os
import crcmod
import random
import string
do_crc64 = crcmod.mkCrcFun(0x142F0E1EBA9EA3693L, initCrc=0L, xorOut=0xffffffffffffffffL, rev=True)
def check_crc64(local_crc64, oss_crc64, msg="check crc64"):
if local_crc64 ! = oss_crc64:
print "{0} check crc64 failed. local:{1}, oss:{2}.".format(msg, local_crc64, oss_crc64)
return False
else:
print "{0} check crc64 ok.".format(msg)
return True
def random_string(length):
return ''.join(random.choice(string.lowercase) for i in range(length))
bucket = oss2. Bucket(oss2. Auth(access_key_id, access_key_secret), endpoint, bucket_name)
How can i verify Put / Get objects values in Python.
I appreciate any assistance with this.
python alibaba-cloud
New contributor
add a comment |
up vote
0
down vote
favorite
Currently, OSS can return the 64-bit CRC value for an object uploaded in any mode on Alibaba Cloud OSS. To check the data integrity, I can compare the 64-bit CRC value with the locally calculated value.
Below is a Python code which shows how to check data transmission integrity based on the 64-bit CRC value.
import oss2
from oss2.models import PartInfo
import os
import crcmod
import random
import string
do_crc64 = crcmod.mkCrcFun(0x142F0E1EBA9EA3693L, initCrc=0L, xorOut=0xffffffffffffffffL, rev=True)
def check_crc64(local_crc64, oss_crc64, msg="check crc64"):
if local_crc64 ! = oss_crc64:
print "{0} check crc64 failed. local:{1}, oss:{2}.".format(msg, local_crc64, oss_crc64)
return False
else:
print "{0} check crc64 ok.".format(msg)
return True
def random_string(length):
return ''.join(random.choice(string.lowercase) for i in range(length))
bucket = oss2. Bucket(oss2. Auth(access_key_id, access_key_secret), endpoint, bucket_name)
How can i verify Put / Get objects values in Python.
I appreciate any assistance with this.
python alibaba-cloud
New contributor
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Currently, OSS can return the 64-bit CRC value for an object uploaded in any mode on Alibaba Cloud OSS. To check the data integrity, I can compare the 64-bit CRC value with the locally calculated value.
Below is a Python code which shows how to check data transmission integrity based on the 64-bit CRC value.
import oss2
from oss2.models import PartInfo
import os
import crcmod
import random
import string
do_crc64 = crcmod.mkCrcFun(0x142F0E1EBA9EA3693L, initCrc=0L, xorOut=0xffffffffffffffffL, rev=True)
def check_crc64(local_crc64, oss_crc64, msg="check crc64"):
if local_crc64 ! = oss_crc64:
print "{0} check crc64 failed. local:{1}, oss:{2}.".format(msg, local_crc64, oss_crc64)
return False
else:
print "{0} check crc64 ok.".format(msg)
return True
def random_string(length):
return ''.join(random.choice(string.lowercase) for i in range(length))
bucket = oss2. Bucket(oss2. Auth(access_key_id, access_key_secret), endpoint, bucket_name)
How can i verify Put / Get objects values in Python.
I appreciate any assistance with this.
python alibaba-cloud
New contributor
Currently, OSS can return the 64-bit CRC value for an object uploaded in any mode on Alibaba Cloud OSS. To check the data integrity, I can compare the 64-bit CRC value with the locally calculated value.
Below is a Python code which shows how to check data transmission integrity based on the 64-bit CRC value.
import oss2
from oss2.models import PartInfo
import os
import crcmod
import random
import string
do_crc64 = crcmod.mkCrcFun(0x142F0E1EBA9EA3693L, initCrc=0L, xorOut=0xffffffffffffffffL, rev=True)
def check_crc64(local_crc64, oss_crc64, msg="check crc64"):
if local_crc64 ! = oss_crc64:
print "{0} check crc64 failed. local:{1}, oss:{2}.".format(msg, local_crc64, oss_crc64)
return False
else:
print "{0} check crc64 ok.".format(msg)
return True
def random_string(length):
return ''.join(random.choice(string.lowercase) for i in range(length))
bucket = oss2. Bucket(oss2. Auth(access_key_id, access_key_secret), endpoint, bucket_name)
How can i verify Put / Get objects values in Python.
I appreciate any assistance with this.
python alibaba-cloud
python alibaba-cloud
New contributor
New contributor
New contributor
asked Nov 8 at 10:01
Ghulam Qadir
13
13
New contributor
New contributor
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Ghulam Qadir is a new contributor. Be nice, and check out our Code of Conduct.
Ghulam Qadir is a new contributor. Be nice, and check out our Code of Conduct.
Ghulam Qadir is a new contributor. Be nice, and check out our Code of Conduct.
Ghulam Qadir is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53205358%2fcheck-oss-data-transmission-integrity-by-using-64-bit-crc-python%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password