js 代码
- function StrAdd(AddType, SrcStr, Value)
- {
- //AddType 0值加1, 1:模加1
- var BaseStr ="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
- var S = "";
- var CurPos = 0, PrePos = 0, SrcLen=0,BaseLen=0, Index=0;
- var isCarry = 0;
- SrcLen= SrcStr.length;
- BaseLen=BaseStr.length;
- isCarry = Value % BaseLen;
- for( CurPos = SrcLen - 1; CurPos >= 0; CurPos --)
- {
- if (isCarry != 0)
- {
- Index = BaseStr.indexOf(SrcStr.charAt(CurPos)) + isCarry;
- if (Index < -1)
- {
- return "";
- }
- if (Index > BaseLen - 1)
- {
- isCarry = 1;
- S = BaseStr.charAt(Index - BaseLen) + S;
- }
- else
- {
- isCarry = 0;
- S = SrcStr.substring(0, CurPos) + BaseStr.charAt(Index) + S;
- break;
- }
- if (CurPos == 0 && AddType == 0) S = BaseStr.charAt(0) + S;
- }
- else
- {
- break;
- }
- }
- return S;
- }