高手请进!关于字符转码后进行异或操作的问题!

icegoset 2006-09-13 10:52:35
近日以来,小弟遇到这样一个问题:想将一个字符串进行解码。其操作是在字符串异或64得到正确的数据!请问有什么办法可以实现?PB好像没有转二进制的函数!请教高手!
...全文
327 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
polestarxu 2006-09-22
  • 打赏
  • 举报
回复
function bitxor(long value1,value2) return long value

//32位异或运算
For ll_Bit = 0 To 31
If ( ( Mod( Long( Value1 / 2^ll_Bit ), 2 ) = 1 And &
Mod( Long( Value2 / 2^ll_Bit ), 2 ) = 0 ) ) Or &
( ( Mod( Long( Value1 / 2^ll_Bit ), 2 ) = 0 And &
Mod( Long( Value2 / 2^ll_Bit ), 2 ) = 1 ) ) Then
If Not Mod( Long( Value / 2^ll_Bit ), 2 ) > 0 Then
Value += 2^ll_Bit
End If
End If
Next

Return Value

32位异或运算,需要的位数自己调整,或者从右截取.返回值是10进制,需要2进制自己转换
icegoset 2006-09-22
  • 打赏
  • 举报
回复
我顶
icegoset 2006-09-19
  • 打赏
  • 举报
回复
真的没有人知道吗?高手都到哪里去了??
rita187878 2006-09-18
  • 打赏
  • 举报
回复
支持LZ --------------------- |水 是 生 命 之 源! |买 点 卡,拿 工 资 |http://www.p ay 3 6 5.com.cn ---------------------
icegoset 2006-09-15
  • 打赏
  • 举报
回复
难道没有人知道吗??
icegoset 2006-09-13
  • 打赏
  • 举报
回复
现在有个列子如我想将下面的转化成
"beggdmldl" "geeczemzfd" "e" "児泾繕uu" "edf`ledmgdml" "uuuuuuuuuuuuuuuuuuuu" "`dmdef" "於泾燈溁帍潴彗挱眦啎拹樷韩滆祚囙挱敩沐於儓潵脲钼漩溄漤唴殝忐炿uuuuuuuuuuuuuuuuuuuuuuuuuuuu" "}ege|cdlfleecuuu" "dlcczdgzdf" "geelzem" "aadagcdlccdgdfeedf" "e" "gd" "uuuuuuuuu"
将其进行异或85就可以得到
"702218919" "2006/08/31" "0" "朱东晖" "013590182189" "" "518103" "广东省深圳宝安区福永桥头稔山工业区六栋广州瑞景环保设备有限公" "(020)61939006" "1966/12/13" "2008/09/15" "441426196612130013" "0" "1" ""
看各位高手有什么办法实现。分不够再加!
icegoset 2006-09-13
  • 打赏
  • 举报
回复
怎么有点看不懂??ai_bit是什么类型的参数。如何进行转化???
orcd 2006-09-13
  • 打赏
  • 举报
回复
可以模拟,,比如 4 可以转成'100',这样得函数是有写好得
圣殿骑士18 2006-09-13
  • 打赏
  • 举报
回复
//////////////////////////////////////////////////////////////////////////////
//
// Function: of_GetBit
//
// Access: public
//
// Arguments:
// al_decimal Decimal value whose on/off value needs to be determined (e.g. 47).
// ai_bit Position bit from right to left on the Decimal value.
//
// Returns: boolean
// True if the value is On.
// False if the value is Off.
// If any argument's value is NULL, function returns NULL.
//
// Description: Determines if the nth binary bit of a decimal number is
// 1 or 0.
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 5.0 Initial version
// 5.0.03 Fixed problem when dealing with large numbers (>32k)
// from "mod int" to "int mod"
//
//////////////////////////////////////////////////////////////////////////////
//
// Copyright ?1996-1997 Sybase, Inc. and its subsidiaries. All rights reserved.
// Any distribution of the PowerBuilder Foundation Classes (PFC)
// source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////

Boolean lb_null

//Check parameters
If IsNull(al_decimal) or IsNull(ai_bit) then
SetNull(lb_null)
Return lb_null
End If

//Assumption ai_bit is the nth bit counting right to left with
//the leftmost bit being bit one.
//al_decimal is a binary number as a base 10 long.
If Int(Mod(al_decimal / (2 ^(ai_bit - 1)), 2)) > 0 Then
Return True
End If

Return False
///////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// Function: of_BitwiseXor
//
// Access: public
//
// Arguments:
// al_Value1 The first value to be used in the operation (e.g. 55).
// al_Value2 The second value to be used in the operation (e.g. 44).
//
// Returns: Long
// The result of the XOR operation (e.g. 27).
// If either argument's value is NULL, function returns NULL.
//
// Description: Performs a bitwise exclusive OR operation (al_Value1 XOR al_Value2),
// which exclusively ORs each bit of the values.
// (55 XOR 44) = 27
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 5.0 Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
// Copyright ?1996-1997 Sybase, Inc. and its subsidiaries. All rights reserved.
// Any distribution of the PowerBuilder Foundation Classes (PFC)
// source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////

Integer li_Cnt
Long ll_Result
Boolean lb_Value1[32], lb_Value2[32]

// Check for nulls
If IsNull(al_Value1) Or IsNull(al_Value2) Then
SetNull(ll_Result)
Return ll_Result
End If

// Get all bits for both values
For li_Cnt = 1 To 32
lb_Value1[li_Cnt] = of_getbit(al_Value1, li_Cnt)
lb_Value2[li_Cnt] = of_getbit(al_Value2, li_Cnt)
Next

// Perfor the XOR
For li_Cnt = 1 To 32
If (lb_Value1[li_Cnt] And Not lb_Value2[li_Cnt]) Or &
(Not lb_Value1[li_Cnt] And lb_Value2[li_Cnt]) Then
ll_Result = ll_Result + (2^(li_Cnt - 1))
End If
Next

Return ll_Result
zsforever 2006-09-13
  • 打赏
  • 举报
回复
mark

740

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 脚本语言
社区管理员
  • 脚本语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧