当前位置: 首页>>代码示例>>Python>>正文


Python BitVector.intValue方法代码示例

本文整理汇总了Python中BitVector.intValue方法的典型用法代码示例。如果您正苦于以下问题:Python BitVector.intValue方法的具体用法?Python BitVector.intValue怎么用?Python BitVector.intValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BitVector的用法示例。


在下文中一共展示了BitVector.intValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: hash_me_bruh

# 需要导入模块: import BitVector [as 别名]
# 或者: from BitVector import intValue [as 别名]
def hash_me_bruh(blocks,k_arr):
    a,b,c,d,e,f,g,h = a_init,b_init,c_init,d_init,e_init,f_init,g_init,h_init
    for block in blocks:
        msg_sch = get_msg_sch(block)
        for round in range(0,80):
            a_copy = a.deep_copy()
            b_copy = b.deep_copy()
            c_copy = c.deep_copy()
            d_copy = d.deep_copy()
            e_copy = e.deep_copy()
            f_copy = f.deep_copy()
            g_copy = g.deep_copy()
            h_copy = h.deep_copy()
            h = g_copy
            g = f_copy
            f = e_copy
            T1 = (h_copy.intValue() + ch(e_copy,f_copy,g_copy).intValue()) % 2**64
            T1 = (T1 + sige(e_copy).intValue()) % 2**64
            T1 = (T1 + msg_sch[round].intValue()) % 2**64
            T1 = (T1 + k_arr[round].intValue()) % 2**64
            e = BitVector(intVal = (d_copy.intValue() + T1) % 2**64, size = 64)
            d = c_copy
            c = b_copy
            b = a_copy
            T2 = (siga(a_copy).intValue() + maj(a_copy,b_copy,c_copy).intValue()) % 2**64
            a = BitVector(intVal = (T2 + T1) % 2**64, size = 64)
        a = BitVector(intVal = (a_init.intValue() + a.intValue()) % 2**64,size=64)
        b = BitVector(intVal = (b_init.intValue() + b.intValue()) % 2**64,size=64)
        c = BitVector(intVal = (c_init.intValue() + c.intValue()) % 2**64,size=64)
        d = BitVector(intVal = (d_init.intValue() + d.intValue()) % 2**64,size=64)
        e = BitVector(intVal = (e_init.intValue() + e.intValue()) % 2**64,size=64)
        f = BitVector(intVal = (f_init.intValue() + f.intValue()) % 2**64,size=64)
        g = BitVector(intVal = (g_init.intValue() + g.intValue()) % 2**64,size=64)
        h = BitVector(intVal = (h_init.intValue() + h.intValue()) % 2**64,size=64)
    hash_bv = a+b+c+d+e+f+g+h
    f_out = open(outputfile,'w')
    print "SHA-512\n",hash_bv.get_bitvector_in_hex()
    f_out.write(hash_bv.get_bitvector_in_hex())
    f_out.write('\n')
开发者ID:mbaio94,项目名称:ECE404_Assignments,代码行数:41,代码来源:hw07.py

示例2: print

# 需要导入模块: import BitVector [as 别名]
# 或者: from BitVector import intValue [as 别名]
print("\nBit vector constructed from integer 5678:")
print(bv)                                    # 1011000101110
print("\nBit vector constructed from integer 0:")
bv = BitVector(intVal=0)
print(bv)                                    # 0
print("\nBit vector constructed from integer 2:")
bv = BitVector(intVal=2)
print(bv)                                    # 10
print("\nBit vector constructed from integer 3:")
bv = BitVector(intVal=3)
print(bv)                                    # 11
print("\nBit vector constructed from integer 123456:")
bv = BitVector(intVal=123456)
print(bv)                                    # 11110001001000000
print("\nInt value of the previous bit vector as computed by intVal():")
print(bv.intValue())                         # 123456
print("\nInt value of the previous bit vector as computed by int():")
print(int(bv))                               # 123456

# Construct a bit vector from a very large integer:
x = 12345678901234567890123456789012345678901234567890123456789012345678901234567890
bv = BitVector(intVal=x)
print("\nHere is a bit vector constructed from a very large integer:")
print(bv)
print("The integer value of the above bit vector is:%d" % int(bv))

# Construct a bit vector directly from a file-like object:
import io
x = "111100001111"
x = ""
if sys.version_info[0] == 3:    
开发者ID:igalfsg,项目名称:ECE404,代码行数:33,代码来源:BitVectorDemo.py

示例3: BitVector

# 需要导入模块: import BitVector [as 别名]
# 或者: from BitVector import intValue [as 别名]
    # Create a bitvector for storing the output plaintext bit array:
    msg_decrypted_bv = BitVector( size = 0 )                    #(T)

    # Carry out differential XORing of bit blocks and decryption:
    previous_decrypted_block = bv_iv                            #(U)
    for i in range(0, len(encrypted_bv) / BLOCKSIZE):           #(V)
        bv = encrypted_bv[i*BLOCKSIZE:(i+1)*BLOCKSIZE]          #(W)
        temp = bv.deep_copy()                                   #(X)
        bv ^=  previous_decrypted_block                         #(Y)
        previous_decrypted_block = temp                         #(Z)
        bv ^=  key_bv                                           #(a)
        msg_decrypted_bv += bv                                  #(b)

    outputtext = msg_decrypted_bv.getTextFromBitVector()        #(c)
    if marktwain.search(outputtext):
        # Generate the ASCII version of Key
        ascii_key = binascii.unhexlify('%x' % key_bv.intValue()) 
	print "**** WOO HOO ****"
        print "Bit Key      : ", str(key_bv)
        print "Key in ASCII : ", ascii_key
	print "Text: \n", outputtext
	break

###### MODIFICATIONS END #########

# Write the plaintext to the output file:
FILEOUT = open(sys.argv[2], 'w')                                #(d)
FILEOUT.write(outputtext)                                       #(e)
FILEOUT.close()                                                 #(f)
开发者ID:sransara,项目名称:rocket-science,代码行数:31,代码来源:cryptBreak.py


注:本文中的BitVector.intValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。