提供openssl -aes-256-cbc兼容加密/解密的简单python函数

原文链接:http://joelinoff.com/blog/?p=885

 

这里的示例显示了如何使用python以与openssl aes-256-cbc完全兼容的方式加密和解密数据。它是基于我在本网站上发布的C ++ Cipher类中所做的工作。它适用于python-2.7和python-3.x。

关键思想是基于openssl生成密钥和iv密码的数据以及它使用的“Salted__”前缀的方式。

 

因为我也掌握openssl的内部细节,所以先留着,等以后要是遇到需要了,在研究

使用方法

提供openssl -aes-256-cbc兼容加密/解密的简单python函数_第1张图片

代码:

#!/usr/bin/env python
'''
Implement openssl compatible AES-256 CBC mode encryption/decryption.

This module provides encrypt() and decrypt() functions that are compatible
with the openssl algorithms.

This is basically a python encoding of my C++ work on the Cipher class
using the Crypto.Cipher.AES class.

URL: http://projects.joelinoff.com/cipher-1.1/doxydocs/html/
'''

# LICENSE
#
# MIT Open Source
#
# Copyright (c) 2014 Joe Linoff
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
# (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import argparse
import base64
import os
import re
import hashlib
import inspect
import sys
from getpass import getpass
from Crypto.Cipher import AES

VERSION='1.2'


# ================================================================
# debug
# ================================================================
def _debug(msg, lev=1):
    '''
    Print a debug message with some context.
    '''
    sys.stderr.write('DEBUG:{} ofp {}\n'.format(inspect.stack()[lev][2], msg))


# ================================================================
# get_key_and_iv
# ================================================================
def get_key_and_iv(password, salt, klen=32, ilen=16, msgdgst='md5'):
    '''
    Derive the key and the IV from the given password and salt.

    This is a niftier implementation than my direct transliteration of
    the C++ code although I modified to support different digests.

    CITATION: http://stackoverflow.com/questions/13907841/implement-openssl-aes-encryption-in-python

    @param password  The password to use as the seed.
    @param salt      The salt.
    @param klen      The key length.
    @param ilen      The initialization vector length.
    @param msgdgst   The message digest algorithm to use.
    '''
    # equivalent to:
    #   from hashlib import  as mdf
    #   from hashlib import md5 as mdf
    #   from hashlib import sha512 as mdf
    mdf = getattr(__import__('hashlib', fromlist=[msgdgst]), msgdgst)
    password = password.encode('ascii', 'ignore')  # convert to ASCII

    try:
        maxlen = klen + ilen
        keyiv = mdf(password + salt).digest()
        tmp = [keyiv]
        while len(tmp) < maxlen:
            tmp.append( mdf(tmp[-1] + password + salt).digest() )
            keyiv += tmp[-1]  # append the last byte
        key = keyiv[:klen]
        iv = keyiv[klen:klen+ilen]
        return key, iv
    except UnicodeDecodeError:
        return None, None


# ================================================================
# encrypt
# ================================================================
def encrypt(password, plaintext, chunkit=True, msgdgst='md5'):
    '''
    Encrypt the plaintext using the password using an openssl
    compatible encryption algorithm. It is the same as creating a file
    with plaintext contents and running openssl like this:

    $ cat plaintext
    
    $ openssl enc -e -aes-256-cbc -base64 -salt \\
        -pass pass:<password> -n plaintext

    @param password  The password.
    @param plaintext The plaintext to encrypt.
    @param chunkit   Flag that tells encrypt to split the ciphertext
                     into 64 character (MIME encoded) lines.
                     This does not affect the decrypt operation.
    @param msgdgst   The message digest algorithm.
    </span><span style="color:#800000;">'''</span><span style="color:#000000;">
    salt </span>= os.urandom(8<span style="color:#000000;">)
    key, iv </span>= get_key_and_iv(password, salt, msgdgst=<span style="color:#000000;">msgdgst)
    </span><span style="color:#0000ff;">if</span> key <span style="color:#0000ff;">is</span><span style="color:#000000;"> None:
        </span><span style="color:#0000ff;">return</span><span style="color:#000000;"> None

    </span><span style="color:#008000;">#</span><span style="color:#008000;"> PKCS#7 padding</span>
    padding_len = 16 - (len(plaintext) % 16<span style="color:#000000;">)
    </span><span style="color:#0000ff;">if</span><span style="color:#000000;"> isinstance(plaintext, str):
        padded_plaintext </span>= plaintext + (chr(padding_len) *<span style="color:#000000;"> padding_len)
    </span><span style="color:#0000ff;">else</span>: <span style="color:#008000;">#</span><span style="color:#008000;"> assume bytes</span>
        padded_plaintext = plaintext + (bytearray([padding_len] *<span style="color:#000000;"> padding_len))

    </span><span style="color:#008000;">#</span><span style="color:#008000;"> Encrypt</span>
    cipher =<span style="color:#000000;"> AES.new(key, AES.MODE_CBC, iv)
    ciphertext </span>=<span style="color:#000000;"> cipher.encrypt(padded_plaintext)

    </span><span style="color:#008000;">#</span><span style="color:#008000;"> Make openssl compatible.</span>
    <span style="color:#008000;">#</span><span style="color:#008000;"> I first discovered this when I wrote the C++ Cipher class.</span>
    <span style="color:#008000;">#</span><span style="color:#008000;"> CITATION: http://projects.joelinoff.com/cipher-1.1/doxydocs/html/</span>
    openssl_ciphertext = b<span style="color:#800000;">'</span><span style="color:#800000;">Salted__</span><span style="color:#800000;">'</span> + salt +<span style="color:#000000;"> ciphertext
    b64 </span>=<span style="color:#000000;"> base64.b64encode(openssl_ciphertext)
    </span><span style="color:#0000ff;">if</span> <span style="color:#0000ff;">not</span><span style="color:#000000;"> chunkit:
        </span><span style="color:#0000ff;">return</span><span style="color:#000000;"> b64

    LINELEN </span>= 64<span style="color:#000000;">
    chunk </span>= <span style="color:#0000ff;">lambda</span> s: b<span style="color:#800000;">'</span><span style="color:#800000;">\n</span><span style="color:#800000;">'</span>.join(s[i:min(i+<span style="color:#000000;">LINELEN, len(s))]
                                </span><span style="color:#0000ff;">for</span> i <span style="color:#0000ff;">in</span><span style="color:#000000;"> range(0, len(s), LINELEN))
    </span><span style="color:#0000ff;">return</span><span style="color:#000000;"> chunk(b64)


</span><span style="color:#008000;">#</span><span style="color:#008000;"> ================================================================</span><span style="color:#008000;">
#</span><span style="color:#008000;"> decrypt</span><span style="color:#008000;">
#</span><span style="color:#008000;"> ================================================================</span>
<span style="color:#0000ff;">def</span> decrypt(password, ciphertext, msgdgst=<span style="color:#800000;">'</span><span style="color:#800000;">md5</span><span style="color:#800000;">'</span><span style="color:#000000;">):
    </span><span style="color:#800000;">'''</span><span style="color:#800000;">
    Decrypt the ciphertext using the password using an openssl
    compatible decryption algorithm. It is the same as creating a file
    with ciphertext contents and running openssl like this:

    $ cat ciphertext
    # ENCRYPTED
    <ciphertext>
    $ egrep -v '^#|^$' | \\
        openssl enc -d -aes-256-cbc -base64 -salt -pass pass:<password> -in ciphertext
    @param password   The password.
    @param ciphertext The ciphertext to decrypt.
    @param msgdgst    The message digest algorithm.
    @returns the decrypted data.
    </span><span style="color:#800000;">'''</span>

    <span style="color:#008000;">#</span><span style="color:#008000;"> unfilter -- ignore blank lines and comments</span>
    <span style="color:#0000ff;">if</span><span style="color:#000000;"> isinstance(ciphertext, str):
        filtered </span>= <span style="color:#800000;">''</span><span style="color:#000000;">
        nl </span>= <span style="color:#800000;">'</span><span style="color:#800000;">\n</span><span style="color:#800000;">'</span><span style="color:#000000;">
        re1 </span>= r<span style="color:#800000;">'</span><span style="color:#800000;">^\s*$</span><span style="color:#800000;">'</span><span style="color:#000000;">
        re2 </span>= r<span style="color:#800000;">'</span><span style="color:#800000;">^\s*#</span><span style="color:#800000;">'</span>
    <span style="color:#0000ff;">else</span><span style="color:#000000;">:
        filtered </span>= b<span style="color:#800000;">''</span><span style="color:#000000;">
        nl </span>= b<span style="color:#800000;">'</span><span style="color:#800000;">\n</span><span style="color:#800000;">'</span><span style="color:#000000;">
        re1 </span>= b<span style="color:#800000;">'</span><span style="color:#800000;">^\\s*$</span><span style="color:#800000;">'</span><span style="color:#000000;">
        re2 </span>= b<span style="color:#800000;">'</span><span style="color:#800000;">^\\s*#</span><span style="color:#800000;">'</span>
        
    <span style="color:#0000ff;">for</span> line <span style="color:#0000ff;">in</span><span style="color:#000000;"> ciphertext.split(nl):
        line </span>=<span style="color:#000000;"> line.strip()
        </span><span style="color:#0000ff;">if</span> re.search(re1,line) <span style="color:#0000ff;">or</span><span style="color:#000000;"> re.search(re2, line):
            </span><span style="color:#0000ff;">continue</span><span style="color:#000000;">
        filtered </span>+= line +<span style="color:#000000;"> nl

    </span><span style="color:#008000;">#</span><span style="color:#008000;"> Base64 decode</span>
    raw =<span style="color:#000000;"> base64.b64decode(filtered)
    </span><span style="color:#0000ff;">assert</span>(raw[:8] == b<span style="color:#800000;">'</span><span style="color:#800000;">Salted__</span><span style="color:#800000;">'</span><span style="color:#000000;"> )
    salt </span>= raw[8:16]  <span style="color:#008000;">#</span><span style="color:#008000;"> get the salt</span>

    <span style="color:#008000;">#</span><span style="color:#008000;"> Now create the key and iv.</span>
    key, iv = get_key_and_iv(password, salt, msgdgst=<span style="color:#000000;">msgdgst)
    </span><span style="color:#0000ff;">if</span> key <span style="color:#0000ff;">is</span><span style="color:#000000;"> None:
        </span><span style="color:#0000ff;">return</span><span style="color:#000000;"> None

    </span><span style="color:#008000;">#</span><span style="color:#008000;"> The original ciphertext</span>
    ciphertext = raw[16<span style="color:#000000;">:]

    </span><span style="color:#008000;">#</span><span style="color:#008000;"> Decrypt</span>
    cipher =<span style="color:#000000;"> AES.new(key, AES.MODE_CBC, iv)
    padded_plaintext </span>=<span style="color:#000000;"> cipher.decrypt(ciphertext)

    </span><span style="color:#0000ff;">if</span><span style="color:#000000;"> isinstance(padded_plaintext, str):
        padding_len </span>= ord(padded_plaintext[-1<span style="color:#000000;">])
    </span><span style="color:#0000ff;">else</span><span style="color:#000000;">:
        padding_len </span>= padded_plaintext[-1<span style="color:#000000;">]
    plaintext </span>= padded_plaintext[:-<span style="color:#000000;">padding_len]
    </span><span style="color:#0000ff;">return</span><span style="color:#000000;"> plaintext

</span><span style="color:#008000;">#</span><span style="color:#008000;"> include the code above ...</span><span style="color:#008000;">
#</span><span style="color:#008000;"> ================================================================</span><span style="color:#008000;">
#</span><span style="color:#008000;"> _open_ios</span><span style="color:#008000;">
#</span><span style="color:#008000;"> ================================================================</span>
<span style="color:#0000ff;">def</span><span style="color:#000000;"> _open_ios(args):
    </span><span style="color:#800000;">'''</span><span style="color:#800000;">
    Open the IO files.
    </span><span style="color:#800000;">'''</span><span style="color:#000000;">
    ifp </span>=<span style="color:#000000;"> sys.stdin
    ofp </span>=<span style="color:#000000;"> sys.stdout

    </span><span style="color:#0000ff;">if</span> args.input <span style="color:#0000ff;">is</span> <span style="color:#0000ff;">not</span><span style="color:#000000;"> None:
        </span><span style="color:#0000ff;">try</span><span style="color:#000000;">:
            ifp </span>= open(args.input, <span style="color:#800000;">'</span><span style="color:#800000;">rb</span><span style="color:#800000;">'</span><span style="color:#000000;">)
        </span><span style="color:#0000ff;">except</span><span style="color:#000000;"> IOError:
            </span><span style="color:#0000ff;">print</span>(<span style="color:#800000;">'</span><span style="color:#800000;">ERROR: cannot read file: {}</span><span style="color:#800000;">'</span><span style="color:#000000;">.format(args.input))
            sys.exit(</span>1<span style="color:#000000;">)

    </span><span style="color:#0000ff;">if</span> args.output <span style="color:#0000ff;">is</span> <span style="color:#0000ff;">not</span><span style="color:#000000;"> None:
        </span><span style="color:#0000ff;">try</span><span style="color:#000000;">:
            ofp </span>= open(args.output, <span style="color:#800000;">'</span><span style="color:#800000;">wb</span><span style="color:#800000;">'</span><span style="color:#000000;">)
        </span><span style="color:#0000ff;">except</span><span style="color:#000000;"> IOError:
            </span><span style="color:#0000ff;">print</span>(<span style="color:#800000;">'</span><span style="color:#800000;">ERROR: cannot write file: {}</span><span style="color:#800000;">'</span><span style="color:#000000;">.format(args.output))
            sys.exit(</span>1<span style="color:#000000;">)

    </span><span style="color:#0000ff;">return</span><span style="color:#000000;"> ifp, ofp


</span><span style="color:#008000;">#</span><span style="color:#008000;"> ================================================================</span><span style="color:#008000;">
#</span><span style="color:#008000;"> _close_ios</span><span style="color:#008000;">
#</span><span style="color:#008000;"> ================================================================</span>
<span style="color:#0000ff;">def</span><span style="color:#000000;"> _close_ios(ifp, ofp):
    </span><span style="color:#800000;">'''</span><span style="color:#800000;">
    Close the IO files if necessary.
    </span><span style="color:#800000;">'''</span>
    <span style="color:#0000ff;">if</span> ifp !=<span style="color:#000000;"> sys.stdin:
        ifp.close()

    </span><span style="color:#0000ff;">if</span> ofp !=<span style="color:#000000;"> sys.stdout:
        ofp.close()


</span><span style="color:#008000;">#</span><span style="color:#008000;"> ================================================================</span><span style="color:#008000;">
#</span><span style="color:#008000;"> _write</span><span style="color:#008000;">
#</span><span style="color:#008000;"> ================================================================</span>
<span style="color:#0000ff;">def</span> _write(ofp, out, newline=<span style="color:#000000;">False):
    </span><span style="color:#800000;">'''</span><span style="color:#800000;">
    Write out the data in the correct format.
    </span><span style="color:#800000;">'''</span>
    <span style="color:#0000ff;">if</span> ofp == sys.stdout <span style="color:#0000ff;">and</span><span style="color:#000000;"> isinstance(out, bytes):
        out </span>= out.decode(<span style="color:#800000;">'</span><span style="color:#800000;">utf-8</span><span style="color:#800000;">'</span>, <span style="color:#800000;">'</span><span style="color:#800000;">ignored</span><span style="color:#800000;">'</span><span style="color:#000000;">)
        ofp.write(out)
        </span><span style="color:#0000ff;">if</span><span style="color:#000000;"> newline:
            ofp.write(</span><span style="color:#800000;">'</span><span style="color:#800000;">\n</span><span style="color:#800000;">'</span><span style="color:#000000;">)
    </span><span style="color:#0000ff;">elif</span><span style="color:#000000;"> isinstance(out, str):
        ofp.write(out)
        </span><span style="color:#0000ff;">if</span><span style="color:#000000;"> newline:
            ofp.write(</span><span style="color:#800000;">'</span><span style="color:#800000;">\n</span><span style="color:#800000;">'</span><span style="color:#000000;">)
    </span><span style="color:#0000ff;">else</span>:  <span style="color:#008000;">#</span><span style="color:#008000;"> assume bytes</span>
<span style="color:#000000;">        ofp.write(out)
        </span><span style="color:#0000ff;">if</span><span style="color:#000000;"> newline:
            ofp.write(b</span><span style="color:#800000;">'</span><span style="color:#800000;">\n</span><span style="color:#800000;">'</span><span style="color:#000000;">)
    

</span><span style="color:#008000;">#</span><span style="color:#008000;"> ================================================================</span><span style="color:#008000;">
#</span><span style="color:#008000;"> _write</span><span style="color:#008000;">
#</span><span style="color:#008000;"> ================================================================</span>
<span style="color:#0000ff;">def</span><span style="color:#000000;"> _read(ifp):
    </span><span style="color:#800000;">'''</span><span style="color:#800000;">
    Read the data in the correct format.
    </span><span style="color:#800000;">'''</span>
    <span style="color:#0000ff;">return</span><span style="color:#000000;"> ifp.read()


</span><span style="color:#008000;">#</span><span style="color:#008000;"> ================================================================</span><span style="color:#008000;">
#</span><span style="color:#008000;"> _runenc</span><span style="color:#008000;">
#</span><span style="color:#008000;"> ================================================================</span>
<span style="color:#0000ff;">def</span><span style="color:#000000;"> _runenc(args):
    </span><span style="color:#800000;">'''</span><span style="color:#800000;">
    Encrypt data.
    </span><span style="color:#800000;">'''</span>
    <span style="color:#0000ff;">if</span> args.passphrase <span style="color:#0000ff;">is</span><span style="color:#000000;"> None:
        </span><span style="color:#0000ff;">while</span><span style="color:#000000;"> True:
            passphrase </span>= getpass(<span style="color:#800000;">'</span><span style="color:#800000;">Passphrase: </span><span style="color:#800000;">'</span><span style="color:#000000;">)
            tmp </span>= getpass(<span style="color:#800000;">'</span><span style="color:#800000;">Re-enter passphrase: </span><span style="color:#800000;">'</span><span style="color:#000000;">)
            </span><span style="color:#0000ff;">if</span> passphrase ==<span style="color:#000000;"> tmp:
                </span><span style="color:#0000ff;">break</span>
            <span style="color:#0000ff;">print</span>(<span style="color:#800000;">''</span><span style="color:#000000;">)
            </span><span style="color:#0000ff;">print</span>(<span style="color:#800000;">'</span><span style="color:#800000;">Passphrases do not match, please try again.</span><span style="color:#800000;">'</span><span style="color:#000000;">)
    </span><span style="color:#0000ff;">else</span><span style="color:#000000;">:
        passphrase </span>=<span style="color:#000000;"> args.passphrase

    ifp, ofp </span>=<span style="color:#000000;"> _open_ios(args)
    text </span>=<span style="color:#000000;"> _read(ifp)
    out </span>= encrypt(passphrase, text, msgdgst=<span style="color:#000000;">args.msgdgst)
    _write(ofp, out, True)
    _close_ios(ifp, ofp)


</span><span style="color:#008000;">#</span><span style="color:#008000;"> ================================================================</span><span style="color:#008000;">
#</span><span style="color:#008000;"> _rundec</span><span style="color:#008000;">
#</span><span style="color:#008000;"> ================================================================</span>
<span style="color:#0000ff;">def</span><span style="color:#000000;"> _rundec(args):
    </span><span style="color:#800000;">'''</span><span style="color:#800000;">
    Decrypt data.
    </span><span style="color:#800000;">'''</span>
    <span style="color:#0000ff;">if</span> args.passphrase <span style="color:#0000ff;">is</span><span style="color:#000000;"> None:
        passphrase </span>= getpass(<span style="color:#800000;">'</span><span style="color:#800000;">Passphrase: </span><span style="color:#800000;">'</span><span style="color:#000000;">)
    </span><span style="color:#0000ff;">else</span><span style="color:#000000;">:
        passphrase </span>=<span style="color:#000000;"> args.passphrase

    ifp, ofp </span>=<span style="color:#000000;"> _open_ios(args)
    text </span>=<span style="color:#000000;"> _read(ifp)
    out </span>= decrypt(passphrase, text, msgdgst=<span style="color:#000000;">args.msgdgst)
    _write(ofp, out, False)
    _close_ios(ifp, ofp)


</span><span style="color:#008000;">#</span><span style="color:#008000;"> ================================================================</span><span style="color:#008000;">
#</span><span style="color:#008000;"> _runtest</span><span style="color:#008000;">
#</span><span style="color:#008000;"> ================================================================</span>
<span style="color:#0000ff;">def</span><span style="color:#000000;"> _runtest(args):
    </span><span style="color:#800000;">'''</span><span style="color:#800000;">
    Run a series of iteration where each iteration generates a random
    password from 8-32 characters and random text from 20 to 256
    characters. The encrypts and decrypts the random data. It then
    compares the results to make sure that everything works correctly.

    The test output looks like this:

    $ crypt 2000
    2000 of 2000 100.00%  15 139 2000    0
    $ #     ^    ^        ^  ^   ^       ^
    $ #     |    |        |  |   |       +-- num failed
    $ #     |    |        |  |   +---------- num passed
    $ #     |    |        |  +-------------- size of text for a test
    $ #     |    |        +----------------- size of passphrase for a test
    $ #     |    +-------------------------- percent completed
    $ #     +------------------------------- total
    # #+------------------------------------ current test

    @param args  The args parse arguments.
    </span><span style="color:#800000;">'''</span>
    <span style="color:#0000ff;">import</span><span style="color:#000000;"> string
    </span><span style="color:#0000ff;">import</span><span style="color:#000000;"> random
    </span><span style="color:#0000ff;">from</span> random <span style="color:#0000ff;">import</span><span style="color:#000000;"> randint

    </span><span style="color:#008000;">#</span><span style="color:#008000;"> Encrypt/decrypt N random sets of plaintext and passwords.</span>
    num =<span style="color:#000000;"> args.test
    ofp </span>=<span style="color:#000000;"> sys.stdout
    </span><span style="color:#0000ff;">if</span> args.output <span style="color:#0000ff;">is</span> <span style="color:#0000ff;">not</span><span style="color:#000000;"> None:
        </span><span style="color:#0000ff;">try</span><span style="color:#000000;">:
            ofp </span>= open(args.output, <span style="color:#800000;">'</span><span style="color:#800000;">w</span><span style="color:#800000;">'</span><span style="color:#000000;">)
        </span><span style="color:#0000ff;">except</span><span style="color:#000000;"> IOError:
            </span><span style="color:#0000ff;">print</span>(<span style="color:#800000;">'</span><span style="color:#800000;">ERROR: can open file for writing: {}</span><span style="color:#800000;">'</span><span style="color:#000000;">.format(args.output))
            sys.exit(</span>1<span style="color:#000000;">)

    chset </span>=<span style="color:#000000;"> string.printable
    passed </span>=<span style="color:#000000;"> 0
    failed </span>=<span style="color:#000000;"> []
    maxlen </span>=<span style="color:#000000;"> len(str(num))
    </span><span style="color:#0000ff;">for</span> i <span style="color:#0000ff;">in</span><span style="color:#000000;"> range(num):
        ran1 </span>= randint(8,32<span style="color:#000000;">)
        password </span>= <span style="color:#800000;">''</span>.join(random.choice(chset) <span style="color:#0000ff;">for</span> x <span style="color:#0000ff;">in</span><span style="color:#000000;"> range(ran1))

        ran2 </span>= randint(20, 256<span style="color:#000000;">)
        plaintext </span>= <span style="color:#800000;">''</span>.join(random.choice(chset) <span style="color:#0000ff;">for</span> x <span style="color:#0000ff;">in</span><span style="color:#000000;"> range(ran2))

        ciphertext </span>= encrypt(password, plaintext, msgdgst=<span style="color:#000000;">args.msgdgst)
        verification </span>= decrypt(password, ciphertext, msgdgst=<span style="color:#000000;">args.msgdgst)

        </span><span style="color:#0000ff;">if</span> plaintext !=<span style="color:#000000;"> verification:
            failed.append( [password, plaintext] )
        </span><span style="color:#0000ff;">else</span><span style="color:#000000;">:
            passed </span>+= 1<span style="color:#000000;">

        output </span>= <span style="color:#800000;">'</span><span style="color:#800000;">%*d of %d %6.2f%% %3d %3d %*d %*d %s</span><span style="color:#800000;">'</span> % (maxlen,i+1<span style="color:#000000;">,
                                                           num,
                                                           </span>100*(i+1)/<span style="color:#000000;">num,
                                                           len(password),
                                                           len(plaintext),
                                                           maxlen, passed,
                                                           maxlen, len(failed),
                                                           args.msgdgst)
        </span><span style="color:#0000ff;">if</span> args.output <span style="color:#0000ff;">is</span><span style="color:#000000;"> None:
            ofp.write(</span><span style="color:#800000;">'</span><span style="color:#800000;">\b</span><span style="color:#800000;">'</span>*80<span style="color:#000000;">)
            ofp.write(output)
            ofp.flush()
        </span><span style="color:#0000ff;">else</span><span style="color:#000000;">:
            ofp.write(output</span>+<span style="color:#800000;">'</span><span style="color:#800000;">\n</span><span style="color:#800000;">'</span><span style="color:#000000;">)

    ofp.write(</span><span style="color:#800000;">'</span><span style="color:#800000;">\n</span><span style="color:#800000;">'</span><span style="color:#000000;">)

    </span><span style="color:#0000ff;">if</span><span style="color:#000000;"> len(failed):
        </span><span style="color:#0000ff;">for</span> i <span style="color:#0000ff;">in</span><span style="color:#000000;"> range(len(failed)):
            ofp.write(</span><span style="color:#800000;">'</span><span style="color:#800000;">%3d %2d %-34s %3d %s\n</span><span style="color:#800000;">'</span> %<span style="color:#000000;"> (i,
                                                  len(failed[i][0]),
                                                  </span><span style="color:#800000;">'</span><span style="color:#800000;">"</span><span style="color:#800000;">'</span>+failed[i][0]+<span style="color:#800000;">'</span><span style="color:#800000;">"</span><span style="color:#800000;">'</span><span style="color:#000000;">,
                                                  len(failed[i][</span>1<span style="color:#000000;">]),
                                                  </span><span style="color:#800000;">'</span><span style="color:#800000;">"</span><span style="color:#800000;">'</span>+failed[i][1]+<span style="color:#800000;">'</span><span style="color:#800000;">"</span><span style="color:#800000;">'</span><span style="color:#000000;">))
        ofp.write(</span><span style="color:#800000;">'</span><span style="color:#800000;">\n</span><span style="color:#800000;">'</span><span style="color:#000000;">)

    </span><span style="color:#0000ff;">if</span> args.output <span style="color:#0000ff;">is</span> <span style="color:#0000ff;">not</span><span style="color:#000000;"> None:
        ofp.close()


</span><span style="color:#008000;">#</span><span style="color:#008000;"> ================================================================</span><span style="color:#008000;">
#</span><span style="color:#008000;"> _cli_opts</span><span style="color:#008000;">
#</span><span style="color:#008000;"> ================================================================</span>
<span style="color:#0000ff;">def</span><span style="color:#000000;"> _cli_opts():
    </span><span style="color:#800000;">'''</span><span style="color:#800000;">
    Parse command line options.
    @returns the arguments
    </span><span style="color:#800000;">'''</span><span style="color:#000000;">
    mepath </span>= os.path.abspath(sys.argv[0]).encode(<span style="color:#800000;">'</span><span style="color:#800000;">utf-8</span><span style="color:#800000;">'</span><span style="color:#000000;">)
    mebase </span>=<span style="color:#000000;"> os.path.basename(mepath)

    description </span>= <span style="color:#800000;">'''</span><span style="color:#800000;">
        Implements encryption/decryption that is compatible with openssl
        AES-256 CBC mode.

        You can use it as follows:

            EXAMPLE 1: {0} -> {0} (MD5)
                $ # Encrypt and decrypt using {0}.
                $ echo 'Lorem ipsum dolor sit amet' | \\
                    {0} -e -p secret | \\
                    {0} -d -p secret
                Lorem ipsum dolor sit amet

            EXAMPLE 2: {0} -> openssl (MD5)
                $ # Encrypt using {0} and decrypt using openssl.
                $ echo 'Lorem ipsum dolor sit amet' | \\
                    {0} -e -p secret | \\
                    openssl enc -d -aes-256-cbc -md md5 -base64 -salt -pass pass:secret
                Lorem ipsum dolor sit amet

            EXAMPLE 3: openssl -> {0} (MD5)
                $ # Encrypt using openssl and decrypt using {0}
                $ echo 'Lorem ipsum dolor sit amet' | \\
                    openssl enc -e -aes-256-cbc -md md5 -base64 -salt -pass pass:secret
                    {0} -d -p secret
                Lorem ipsum dolor sit amet

            EXAMPLE 4: openssl -> openssl (MD5)
                $ # Encrypt and decrypt using openssl
                $ echo 'Lorem ipsum dolor sit amet' | \\
                    openssl enc -e -aes-256-cbc -md md5 -base64 -salt -pass pass:secret
                    openssl enc -d -aes-256-cbc -md md5 -base64 -salt -pass pass:secret
                Lorem ipsum dolor sit amet

            EXAMPLE 5: {0} -> {0} (SHA512)
                $ # Encrypt and decrypt using {0}.
                $ echo 'Lorem ipsum dolor sit amet' | \\
                    {0} -e -m sha512 -p secret | \\
                    {0} -d -m sha512 -p secret
                Lorem ipsum dolor sit amet

            EXAMPLE 6: {0} -> openssl (SHA512)
                $ # Encrypt using {0} and decrypt using openssl.
                $ echo 'Lorem ipsum dolor sit amet' | \\
                    {0} -e -m sha512 -p secret | \\
                    openssl enc -d -aes-256-cbc -md sha1=512 -base64 -salt -pass pass:secret
                Lorem ipsum dolor sit amet

            EXAMPLE 7:
                $ # Run internal tests.
                $ {0} -t 2000
                2000 of 2000 100.00%%  21 104 2000    0 md5
                $ #     ^    ^        ^  ^   ^       ^ ^
                $ #     |    |        |  |   |       | +- message digest
                $ #     |    |        |  |   |       +--- num failed
                $ #     |    |        |  |   +----------- num passed
                $ #     |    |        |  +--------------- size of text for a test
                $ #     |    |        +------------------ size of passphrase for a test
                $ #     |    +--------------------------- percent completed
                $ #     +-------------------------------- total
                # #+------------------------------------- current test
</span><span style="color:#800000;">'''</span>.format(mebase.decode(<span style="color:#800000;">'</span><span style="color:#800000;">ascii</span><span style="color:#800000;">'</span>, <span style="color:#800000;">'</span><span style="color:#800000;">ignore</span><span style="color:#800000;">'</span><span style="color:#000000;">))

    parser </span>= argparse.ArgumentParser(prog=<span style="color:#000000;">mebase,
                                     formatter_class</span>=<span style="color:#000000;">argparse.RawDescriptionHelpFormatter,
                                     description</span>=<span style="color:#000000;">description,
                                     )

    group </span>= parser.add_mutually_exclusive_group(required=<span style="color:#000000;">True)
    group.add_argument(</span><span style="color:#800000;">'</span><span style="color:#800000;">-d</span><span style="color:#800000;">'</span>, <span style="color:#800000;">'</span><span style="color:#800000;">--decrypt</span><span style="color:#800000;">'</span><span style="color:#000000;">,
                       action</span>=<span style="color:#800000;">'</span><span style="color:#800000;">store_true</span><span style="color:#800000;">'</span><span style="color:#000000;">,
                       help</span>=<span style="color:#800000;">'</span><span style="color:#800000;">decryption mode</span><span style="color:#800000;">'</span><span style="color:#000000;">)
    group.add_argument(</span><span style="color:#800000;">'</span><span style="color:#800000;">-e</span><span style="color:#800000;">'</span>, <span style="color:#800000;">'</span><span style="color:#800000;">--encrypt</span><span style="color:#800000;">'</span><span style="color:#000000;">,
                       action</span>=<span style="color:#800000;">'</span><span style="color:#800000;">store_true</span><span style="color:#800000;">'</span><span style="color:#000000;">,
                       help</span>=<span style="color:#800000;">'</span><span style="color:#800000;">encryption mode</span><span style="color:#800000;">'</span><span style="color:#000000;">)
    parser.add_argument(</span><span style="color:#800000;">'</span><span style="color:#800000;">-i</span><span style="color:#800000;">'</span>, <span style="color:#800000;">'</span><span style="color:#800000;">--input</span><span style="color:#800000;">'</span><span style="color:#000000;">,
                        action</span>=<span style="color:#800000;">'</span><span style="color:#800000;">store</span><span style="color:#800000;">'</span><span style="color:#000000;">,
                        help</span>=<span style="color:#800000;">'</span><span style="color:#800000;">input file, default is stdin</span><span style="color:#800000;">'</span><span style="color:#000000;">)
    parser.add_argument(</span><span style="color:#800000;">'</span><span style="color:#800000;">-m</span><span style="color:#800000;">'</span>, <span style="color:#800000;">'</span><span style="color:#800000;">--msgdgst</span><span style="color:#800000;">'</span><span style="color:#000000;">,
                        action</span>=<span style="color:#800000;">'</span><span style="color:#800000;">store</span><span style="color:#800000;">'</span><span style="color:#000000;">,
                        default</span>=<span style="color:#800000;">'</span><span style="color:#800000;">md5</span><span style="color:#800000;">'</span><span style="color:#000000;">,
                        help</span>=<span style="color:#800000;">'</span><span style="color:#800000;">message digest (md5, sha, sha1, sha256, sha512), default is md5</span><span style="color:#800000;">'</span><span style="color:#000000;">)
    parser.add_argument(</span><span style="color:#800000;">'</span><span style="color:#800000;">-o</span><span style="color:#800000;">'</span>, <span style="color:#800000;">'</span><span style="color:#800000;">--output</span><span style="color:#800000;">'</span><span style="color:#000000;">,
                        action</span>=<span style="color:#800000;">'</span><span style="color:#800000;">store</span><span style="color:#800000;">'</span><span style="color:#000000;">,
                        help</span>=<span style="color:#800000;">'</span><span style="color:#800000;">output file, default is stdout</span><span style="color:#800000;">'</span><span style="color:#000000;">)
    parser.add_argument(</span><span style="color:#800000;">'</span><span style="color:#800000;">-p</span><span style="color:#800000;">'</span>, <span style="color:#800000;">'</span><span style="color:#800000;">--passphrase</span><span style="color:#800000;">'</span><span style="color:#000000;">,
                        action</span>=<span style="color:#800000;">'</span><span style="color:#800000;">store</span><span style="color:#800000;">'</span><span style="color:#000000;">,
                        help</span>=<span style="color:#800000;">'</span><span style="color:#800000;">passphrase for encrypt/decrypt operations</span><span style="color:#800000;">'</span><span style="color:#000000;">)
    group.add_argument(</span><span style="color:#800000;">'</span><span style="color:#800000;">-t</span><span style="color:#800000;">'</span>, <span style="color:#800000;">'</span><span style="color:#800000;">--test</span><span style="color:#800000;">'</span><span style="color:#000000;">,
                       action</span>=<span style="color:#800000;">'</span><span style="color:#800000;">store</span><span style="color:#800000;">'</span><span style="color:#000000;">,
                       default</span>=-1<span style="color:#000000;">,
                       type</span>=<span style="color:#000000;">int,
                       help</span>=<span style="color:#800000;">'</span><span style="color:#800000;">test mode (TEST is an integer)</span><span style="color:#800000;">'</span><span style="color:#000000;">)
    parser.add_argument(</span><span style="color:#800000;">'</span><span style="color:#800000;">-v</span><span style="color:#800000;">'</span>, <span style="color:#800000;">'</span><span style="color:#800000;">--verbose</span><span style="color:#800000;">'</span><span style="color:#000000;">,
                        action</span>=<span style="color:#800000;">'</span><span style="color:#800000;">count</span><span style="color:#800000;">'</span><span style="color:#000000;">,
                        help</span>=<span style="color:#800000;">'</span><span style="color:#800000;">the level of verbosity</span><span style="color:#800000;">'</span><span style="color:#000000;">)
    parser.add_argument(</span><span style="color:#800000;">'</span><span style="color:#800000;">-V</span><span style="color:#800000;">'</span>, <span style="color:#800000;">'</span><span style="color:#800000;">--version</span><span style="color:#800000;">'</span><span style="color:#000000;">,
                        action</span>=<span style="color:#800000;">'</span><span style="color:#800000;">version</span><span style="color:#800000;">'</span><span style="color:#000000;">,
                        version</span>=<span style="color:#800000;">'</span><span style="color:#800000;">%(prog)s </span><span style="color:#800000;">'</span>+<span style="color:#000000;">VERSION)

    args </span>=<span style="color:#000000;"> parser.parse_args()
    </span><span style="color:#0000ff;">return</span><span style="color:#000000;"> args


</span><span style="color:#008000;">#</span><span style="color:#008000;"> ================================================================</span><span style="color:#008000;">
#</span><span style="color:#008000;"> main</span><span style="color:#008000;">
#</span><span style="color:#008000;"> ================================================================</span>
<span style="color:#0000ff;">def</span><span style="color:#000000;"> main():
    args </span>=<span style="color:#000000;"> _cli_opts()
    </span><span style="color:#0000ff;">if</span> args.test ><span style="color:#000000;"> 0:
        </span><span style="color:#0000ff;">if</span> args.input <span style="color:#0000ff;">is</span> <span style="color:#0000ff;">not</span><span style="color:#000000;"> None:
            </span><span style="color:#0000ff;">print</span>(<span style="color:#800000;">'</span><span style="color:#800000;">WARNING: input argument will be ignored.</span><span style="color:#800000;">'</span><span style="color:#000000;">)
        </span><span style="color:#0000ff;">if</span> args.passphrase <span style="color:#0000ff;">is</span> <span style="color:#0000ff;">not</span><span style="color:#000000;"> None:
            </span><span style="color:#0000ff;">print</span>(<span style="color:#800000;">'</span><span style="color:#800000;">WARNING: passphrase argument will be ignored.</span><span style="color:#800000;">'</span><span style="color:#000000;">)
        _runtest(args)
    </span><span style="color:#0000ff;">elif</span><span style="color:#000000;"> args.encrypt:
        _runenc(args)
    </span><span style="color:#0000ff;">elif</span><span style="color:#000000;"> args.decrypt:
        _rundec(args)


</span><span style="color:#008000;">#</span><span style="color:#008000;"> ================================================================</span><span style="color:#008000;">
#</span><span style="color:#008000;"> MAIN</span><span style="color:#008000;">
#</span><span style="color:#008000;"> ================================================================</span>
<span style="color:#0000ff;">if</span> <span style="color:#800080;">__name__</span> == <span style="color:#800000;">"</span><span style="color:#800000;">__main__</span><span style="color:#800000;">"</span><span style="color:#000000;">:
    main()</span></pre> 
    </div> 
    <span class="cnblogs_code_collapse">View Code</span> 
   </div> 
   <p> </p> 
  </div> 
 </div> 
</div>
                            </div>
                        </div>
                    </div>
                    <!--PC和WAP自适应版-->
                    <div id="SOHUCS" sid="1304717771254304768"></div>
                    <script type="text/javascript" src="/views/front/js/chanyan.js"></script>
                    <!-- 文章页-底部 动态广告位 -->
                    <div class="youdao-fixed-ad" id="detail_ad_bottom"></div>
                </div>
                <div class="col-md-3">
                    <div class="row" id="ad">
                        <!-- 文章页-右侧1 动态广告位 -->
                        <div id="right-1" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad">
                            <div class="youdao-fixed-ad" id="detail_ad_1"> </div>
                        </div>
                        <!-- 文章页-右侧2 动态广告位 -->
                        <div id="right-2" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad">
                            <div class="youdao-fixed-ad" id="detail_ad_2"></div>
                        </div>
                        <!-- 文章页-右侧3 动态广告位 -->
                        <div id="right-3" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad">
                            <div class="youdao-fixed-ad" id="detail_ad_3"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="container">
        <h4 class="pt20 mb15 mt0 border-top">你可能感兴趣的:(提供openssl -aes-256-cbc兼容加密/解密的简单python函数)</h4>
        <div id="paradigm-article-related">
            <div class="recommend-post mb30">
                <ul class="widget-links">
                    <li><a href="/article/1835514462770130944.htm"
                           title="斤斤计较的婚姻到底有多难?" target="_blank">斤斤计较的婚姻到底有多难?</a>
                        <span class="text-muted">白心之岂必有为</span>

                        <div>很多人私聊我会问到在哪个人群当中斤斤计较的人最多?我都会回答他,一般婚姻出现问题的斤斤计较的人士会非常多,以我多年经验,在婚姻落的一塌糊涂的人当中,斤斤计较的人数占比在20~30%以上,也就是说10个婚姻出现问题的斤斤计较的人有2-3个有多不减。在婚姻出问题当中,有大量的心理不平衡的、尖酸刻薄的怨妇。在婚姻中仅斤斤计较有两种类型:第一种是物质上的,另一种是精神上的。在物质与精神上抠门已经严重的影响</div>
                    </li>
                    <li><a href="/article/1835514464028422144.htm"
                           title="情绪觉察日记第37天" target="_blank">情绪觉察日记第37天</a>
                        <span class="text-muted">露露_e800</span>

                        <div>今天是家庭关系规划师的第二阶最后一天,慧萍老师帮我做了个案,帮我处理了埋在心底好多年的一份恐惧,并给了我深深的力量!这几天出来学习,爸妈过来婆家帮我带小孩,妈妈出于爱帮我收拾东西,并跟我先生和婆婆产生矛盾,妈妈觉得他们没有照顾好我…。今晚回家见到妈妈,我很欣赏她并赞扬她,妈妈说今晚要跟我睡我说好,当我们俩躺在床上准备睡觉的时候,我握着妈妈的手对她说:妈妈这几天辛苦你了,你看你多利害把我们的家收拾得</div>
                    </li>
                    <li><a href="/article/1835514335561084928.htm"
                           title="芦花鞋一四" target="_blank">芦花鞋一四</a>
                        <span class="text-muted">许叶晗</span>

                        <div>又是在一个寒冷的夏日里,青铜和葵花决定今天一起去卖芦花鞋,奶奶亲手给他们做了一碗热乎乎的粥对他们说:“就靠你们两挣生活费了这碗粥赶紧趁热喝了吧!”于是青铜和葵花喝完了奶奶给她们做的粥,就准备去镇上卖卢花鞋,这回青铜和葵花穿着新的芦花鞋来到了镇上。青铜这回看到了很多人都在卖,用手势表达对葵花说:“这回有好多人在抢我们生意呢!我们必须得吆喝起来。”葵花点了点头。可是谁知他们也大声的叫,卖芦花喽!卖芦花</div>
                    </li>
                    <li><a href="/article/1835514307744460800.htm"
                           title="QQ群采集助手,精准引流必备神器" target="_blank">QQ群采集助手,精准引流必备神器</a>
                        <span class="text-muted">2401_87347160</span>
<a class="tag" taget="_blank" href="/search/%E5%85%B6%E4%BB%96/1.htm">其他</a><a class="tag" taget="_blank" href="/search/%E7%BB%8F%E9%AA%8C%E5%88%86%E4%BA%AB/1.htm">经验分享</a>
                        <div>功能概述微信群查找与筛选工具是一款专为微信用户设计的辅助工具,它通过关键词搜索功能,帮助用户快速找到相关的微信群,并提供筛选是否需要验证的群组的功能。主要功能关键词搜索:用户可以输入关键词,工具将自动查找包含该关键词的微信群。筛选功能:工具提供筛选机制,用户可以选择是否只显示需要验证或不需要验证的群组。精准引流:通过上述功能,用户可以更精准地找到目标群组,进行有效的引流操作。3.设备需求该工具可以</div>
                    </li>
                    <li><a href="/article/1835514207114719232.htm"
                           title="关于沟通这件事,项目经理不需要每次都面对面进行" target="_blank">关于沟通这件事,项目经理不需要每次都面对面进行</a>
                        <span class="text-muted">流程大师兄</span>

                        <div>很多项目经理都会遇到这样的问题,项目中由于事情太多,根本没有足够的时间去召开会议,那在这种情况下如何去有效地管理项目中的利益相关者?当然,不建议电子邮件也不需要开会的话,建议可以采取下面几种方式来形成有效的沟通,这几种方式可以帮助你努力的通过各种办法来保持和各方面的联系。项目经理首先要问自己几个问题,项目中哪些利益相关者是必须要进行沟通的?可以列出项目中所有的利益相关者清单,同时也整理出项目中哪些</div>
                    </li>
                    <li><a href="/article/1835513803861749760.htm"
                           title="机器学习与深度学习间关系与区别" target="_blank">机器学习与深度学习间关系与区别</a>
                        <span class="text-muted">ℒℴѵℯ心·动ꦿ໊ོ꫞</span>
<a class="tag" taget="_blank" href="/search/%E4%BA%BA%E5%B7%A5%E6%99%BA%E8%83%BD/1.htm">人工智能</a><a class="tag" taget="_blank" href="/search/%E5%AD%A6%E4%B9%A0/1.htm">学习</a><a class="tag" taget="_blank" href="/search/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/1.htm">深度学习</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a>
                        <div>一、机器学习概述定义机器学习(MachineLearning,ML)是一种通过数据驱动的方法,利用统计学和计算算法来训练模型,使计算机能够从数据中学习并自动进行预测或决策。机器学习通过分析大量数据样本,识别其中的模式和规律,从而对新的数据进行判断。其核心在于通过训练过程,让模型不断优化和提升其预测准确性。主要类型1.监督学习(SupervisedLearning)监督学习是指在训练数据集中包含输入</div>
                    </li>
                    <li><a href="/article/1835513701143244800.htm"
                           title="铭刻于星(四十二)" target="_blank">铭刻于星(四十二)</a>
                        <span class="text-muted">随风至</span>

                        <div>69夜晚,绍敏同学做完功课后,看了眼房外,没听到动静才敢从书包的夹层里拿出那个心形纸团。折痕压得很深,都有些旧了,想来是已经写好很久了。绍敏同学慢慢地、轻轻地捏开折叠处,待到全部拆开后,又反复抚平纸张,然后仔细地一字字默看。只是开头的三个字是第一次看到,让她心漏跳了几拍。“亲爱的绍敏:从四年级的时候,我就喜欢你了,但是我一直不敢说,怕影响你学习。六年级的时候听说有人跟你表白,你接受了,我很难过,但</div>
                    </li>
                    <li><a href="/article/1835513570171908096.htm"
                           title="底层逆袭到底有多难,不甘平凡的你准备好了吗?让吴起给你说说" target="_blank">底层逆袭到底有多难,不甘平凡的你准备好了吗?让吴起给你说说</a>
                        <span class="text-muted">造命者说</span>

                        <div>底层逆袭到底有多难,不甘平凡的你准备好了吗?让吴起给你说说我叫吴起,生于公元前440年的战国初期,正是群雄并起、天下纷争不断的时候。后人说我是军事家、政治家、改革家,是兵家代表人物。评价我一生历仕鲁、魏、楚三国,通晓兵家、法家、儒家三家思想,在内政军事上都有极高的成就。周安王二十一年(公元前381年),因变法得罪守旧贵族,被人乱箭射死。我出生在卫国一个“家累万金”的富有家庭,从年轻时候起就不甘平凡</div>
                    </li>
                    <li><a href="/article/1835513571501502464.htm"
                           title="2020-01-25" target="_blank">2020-01-25</a>
                        <span class="text-muted">晴岚85</span>

                        <div>郑海燕坚持分享590天2020.1.24在生活中只存在两个问题。一个问题是:你知道想要达成的目标是什么,但却不知道如何才能达成;另一个问题是:你不知道你的目标是什么。前一个是行动的问题,后一个是结果的问题。通过制定具体的下一步行动,可以解决不知道如何开始行动的问题。而通过去想象结果,对结果做预估,可以解决找不着目标的问题。对于所有吸引我们注意力,想要完成的任务,你可以先想象一下,预期的结果究竟是什</div>
                    </li>
                    <li><a href="/article/1835513568917811200.htm"
                           title="随笔 | 仙一般的灵气" target="_blank">随笔 | 仙一般的灵气</a>
                        <span class="text-muted">海思沧海</span>

                        <div>仙岛今天,我看了你全部,似乎已经进入你的世界我不知道,这是否是梦幻,还是你仙一般的灵气吸引了我也许每一个人都要有一份属于自己的追求,这样才能够符合人生的梦想,生活才能够充满着阳光与快乐我不知道,我为什么会这样的感叹,是在感叹自己的人生,还是感叹自己一直没有孜孜不倦的追求只感觉虚度了光阴,每天活在自己的梦中,活在一个不真实的世界是在逃避自己,还是在逃避周围的一切有时候我嘲笑自己,嘲笑自己如此的虚无,</div>
                    </li>
                    <li><a href="/article/1835513567663714304.htm"
                           title="想家" target="_blank">想家</a>
                        <span class="text-muted">爆米花机</span>

                        <div>也许不同于大家对家乡的思念,我对家乡甚至是疯狂的不舍。还未踏出车站就感觉到幸福,我享受这里的夕阳、这里的浓烈柴火味、这里每一口家常菜。我是宅女,我贪恋家的安逸。刚刚踏出大学校门,初出茅庐,无法适应每年只能国庆和春节回家。我焦虑、失眠、无端发脾气,是无法适应工作的节奏,是无法接受我将一步步离开家乡的事实。我不想承认自己胸无大志,选择再次踏上征程。图片发自App</div>
                    </li>
                    <li><a href="/article/1835513551624695808.htm"
                           title="【iOS】MVC设计模式" target="_blank">【iOS】MVC设计模式</a>
                        <span class="text-muted">Magnetic_h</span>
<a class="tag" taget="_blank" href="/search/ios/1.htm">ios</a><a class="tag" taget="_blank" href="/search/mvc/1.htm">mvc</a><a class="tag" taget="_blank" href="/search/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/1.htm">设计模式</a><a class="tag" taget="_blank" href="/search/objective-c/1.htm">objective-c</a><a class="tag" taget="_blank" href="/search/%E5%AD%A6%E4%B9%A0/1.htm">学习</a><a class="tag" taget="_blank" href="/search/ui/1.htm">ui</a>
                        <div>MVC前言如何设计一个程序的结构,这是一门专门的学问,叫做"架构模式"(architecturalpattern),属于编程的方法论。MVC模式就是架构模式的一种。它是Apple官方推荐的App开发架构,也是一般开发者最先遇到、最经典的架构。MVC各层controller层Controller/ViewController/VC(控制器)负责协调Model和View,处理大部分逻辑它将数据从Mod</div>
                    </li>
                    <li><a href="/article/1835513551142350848.htm"
                           title="OC语言多界面传值五大方式" target="_blank">OC语言多界面传值五大方式</a>
                        <span class="text-muted">Magnetic_h</span>
<a class="tag" taget="_blank" href="/search/ios/1.htm">ios</a><a class="tag" taget="_blank" href="/search/ui/1.htm">ui</a><a class="tag" taget="_blank" href="/search/%E5%AD%A6%E4%B9%A0/1.htm">学习</a><a class="tag" taget="_blank" href="/search/objective-c/1.htm">objective-c</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a>
                        <div>前言在完成暑假仿写项目时,遇到了许多需要用到多界面传值的地方,这篇博客来总结一下比较常用的五种多界面传值的方式。属性传值属性传值一般用前一个界面向后一个界面传值,简单地说就是通过访问后一个视图控制器的属性来为它赋值,通过这个属性来做到从前一个界面向后一个界面传值。首先在后一个界面中定义属性@interfaceBViewController:UIViewController@propertyNSSt</div>
                    </li>
                    <li><a href="/article/1835513440525971456.htm"
                           title="一百九十四章. 自相矛盾" target="_blank">一百九十四章. 自相矛盾</a>
                        <span class="text-muted">巨木擎天</span>

                        <div>唉!就这么一夜,林子感觉就像过了很多天似的,先是回了阳间家里,遇到了那么多不可思议的事情儿。特别是小伙伴们,第二次与自己见面时,僵硬的表情和恐怖的气氛,让自己如坐针毡,打从心眼里难受!还有东子,他现在还好吗?有没有被人欺负?护城河里的小鱼小虾们,还都在吗?水不会真的干枯了吧?那对相亲相爱漂亮的太平鸟儿,还好吧!春天了,到了做窝、下蛋、喂养小鸟宝宝的时候了,希望它们都能够平安啊!虽然没有看见家人,也</div>
                    </li>
                    <li><a href="/article/1835513424734416896.htm"
                           title="UI学习——cell的复用和自定义cell" target="_blank">UI学习——cell的复用和自定义cell</a>
                        <span class="text-muted">Magnetic_h</span>
<a class="tag" taget="_blank" href="/search/ui/1.htm">ui</a><a class="tag" taget="_blank" href="/search/%E5%AD%A6%E4%B9%A0/1.htm">学习</a>
                        <div>目录cell的复用手动(非注册)自动(注册)自定义cellcell的复用在iOS开发中,单元格复用是一种提高表格(UITableView)和集合视图(UICollectionView)滚动性能的技术。当一个UITableViewCell或UICollectionViewCell首次需要显示时,如果没有可复用的单元格,则视图会创建一个新的单元格。一旦这个单元格滚动出屏幕,它就不会被销毁。相反,它被添</div>
                    </li>
                    <li><a href="/article/1835512920797179904.htm"
                           title="element实现动态路由+面包屑" target="_blank">element实现动态路由+面包屑</a>
                        <span class="text-muted">软件技术NINI</span>
<a class="tag" taget="_blank" href="/search/vue%E6%A1%88%E4%BE%8B/1.htm">vue案例</a><a class="tag" taget="_blank" href="/search/vue.js/1.htm">vue.js</a><a class="tag" taget="_blank" href="/search/%E5%89%8D%E7%AB%AF/1.htm">前端</a>
                        <div>el-breadcrumb是ElementUI组件库中的一个面包屑导航组件,它用于显示当前页面的路径,帮助用户快速理解和导航到应用的各个部分。在Vue.js项目中,如果你已经安装了ElementUI,就可以很方便地使用el-breadcrumb组件。以下是一个基本的使用示例:安装ElementUI(如果你还没有安装的话):你可以通过npm或yarn来安装ElementUI。bash复制代码npmi</div>
                    </li>
                    <li><a href="/article/1835512809883004928.htm"
                           title="10月|愿你的青春不负梦想-读书笔记-01" target="_blank">10月|愿你的青春不负梦想-读书笔记-01</a>
                        <span class="text-muted">Tracy的小书斋</span>

                        <div>本书的作者是俞敏洪,大家都很熟悉他了吧。俞敏洪老师是我行业的领头羊吧,也是我事业上的偶像。本日摘录他书中第一章中的金句:『一个人如果什么目标都没有,就会浑浑噩噩,感觉生命中缺少能量。能给我们能量的,是对未来的期待。第一件事,我始终为了进步而努力。与其追寻全世界的骏马,不如种植丰美的草原,到时骏马自然会来。第二件事,我始终有阶段性的目标。什么东西能给我能量?答案是对未来的期待。』读到这里的时候,我便</div>
                    </li>
                    <li><a href="/article/1835512542735200256.htm"
                           title="C语言宏函数" target="_blank">C语言宏函数</a>
                        <span class="text-muted">南林yan</span>
<a class="tag" taget="_blank" href="/search/C%E8%AF%AD%E8%A8%80/1.htm">C语言</a><a class="tag" taget="_blank" href="/search/c%E8%AF%AD%E8%A8%80/1.htm">c语言</a>
                        <div>一、什么是宏函数?通过宏定义的函数是宏函数。如下,编译器在预处理阶段会将Add(x,y)替换为((x)*(y))#defineAdd(x,y)((x)*(y))#defineAdd(x,y)((x)*(y))intmain(){inta=10;intb=20;intd=10;intc=Add(a+d,b)*2;cout<<c<<endl;//800return0;}二、为什么要使用宏函数使用宏函数</div>
                    </li>
                    <li><a href="/article/1835512305320816640.htm"
                           title="地推话术,如何应对地推过程中家长的拒绝" target="_blank">地推话术,如何应对地推过程中家长的拒绝</a>
                        <span class="text-muted">校师学</span>

                        <div>相信校长们在做地推的时候经常遇到这种情况:市场专员反馈家长不接单,咨询师反馈难以邀约这些家长上门,校区地推疲软,招生难。为什么?仅从地推层面分析,一方面因为家长受到的信息轰炸越来越多,对信息越来越“免疫”;而另一方面地推人员的专业能力和营销话术没有提高,无法应对家长的拒绝,对有意向的家长也不知如何跟进,眼睁睁看着家长走远;对于家长的疑问,更不知道如何有技巧地回答,机会白白流失。由于回答没技巧和专业</div>
                    </li>
                    <li><a href="/article/1835512178023690240.htm"
                           title="谢谢你们,爱你们!" target="_blank">谢谢你们,爱你们!</a>
                        <span class="text-muted">鹿游儿</span>

                        <div>昨天家人去泡温泉,二个孩子也带着去,出发前一晚,匆匆下班,赶回家和孩子一起收拾。饭后,我拿出笔和本子(上次去澳门时做手帐的本子)写下了1\2\3\4\5\6\7\8\9,让后让小壹去思考,带什么出发去旅游呢?她在对应的数字旁边画上了,泳衣、泳圈、肖恩、内衣内裤、tapuy、拖鞋……画完后,就让她自己对着这个本子,将要带的,一一带上,没想到这次带的书还是这本《便便工厂》(晚上姑婆发照片过来,妹妹累得</div>
                    </li>
                    <li><a href="/article/1835511911769272320.htm"
                           title="C语言如何定义宏函数?" target="_blank">C语言如何定义宏函数?</a>
                        <span class="text-muted">小九格物</span>
<a class="tag" taget="_blank" href="/search/c%E8%AF%AD%E8%A8%80/1.htm">c语言</a>
                        <div>在C语言中,宏函数是通过预处理器定义的,它在编译之前替换代码中的宏调用。宏函数可以模拟函数的行为,但它们不是真正的函数,因为它们在编译时不会进行类型检查,也不会分配存储空间。宏函数的定义通常使用#define指令,后面跟着宏的名称和参数列表,以及宏展开后的代码。宏函数的定义方式:1.基本宏函数:这是最简单的宏函数形式,它直接定义一个表达式。#defineSQUARE(x)((x)*(x))2.带参</div>
                    </li>
                    <li><a href="/article/1835511912192897024.htm"
                           title="微服务下功能权限与数据权限的设计与实现" target="_blank">微服务下功能权限与数据权限的设计与实现</a>
                        <span class="text-muted">nbsaas-boot</span>
<a class="tag" taget="_blank" href="/search/%E5%BE%AE%E6%9C%8D%E5%8A%A1/1.htm">微服务</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/%E6%9E%B6%E6%9E%84/1.htm">架构</a>
                        <div>在微服务架构下,系统的功能权限和数据权限控制显得尤为重要。随着系统规模的扩大和微服务数量的增加,如何保证不同用户和服务之间的访问权限准确、细粒度地控制,成为设计安全策略的关键。本文将讨论如何在微服务体系中设计和实现功能权限与数据权限控制。1.功能权限与数据权限的定义功能权限:指用户或系统角色对特定功能的访问权限。通常是某个用户角色能否执行某个操作,比如查看订单、创建订单、修改用户资料等。数据权限:</div>
                    </li>
                    <li><a href="/article/1835511912843014144.htm"
                           title="理解Gunicorn:Python WSGI服务器的基石" target="_blank">理解Gunicorn:Python WSGI服务器的基石</a>
                        <span class="text-muted">范范0825</span>
<a class="tag" taget="_blank" href="/search/ipython/1.htm">ipython</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/%E8%BF%90%E7%BB%B4/1.htm">运维</a>
                        <div>理解Gunicorn:PythonWSGI服务器的基石介绍Gunicorn,全称GreenUnicorn,是一个为PythonWSGI(WebServerGatewayInterface)应用设计的高效、轻量级HTTP服务器。作为PythonWeb应用部署的常用工具,Gunicorn以其高性能和易用性著称。本文将介绍Gunicorn的基本概念、安装和配置,帮助初学者快速上手。1.什么是Gunico</div>
                    </li>
                    <li><a href="/article/1835511669476913152.htm"
                           title="小丽成长记(四十三)" target="_blank">小丽成长记(四十三)</a>
                        <span class="text-muted">玲玲54321</span>

                        <div>小丽发现,即使她好不容易调整好自己的心态下一秒总会有不确定的伤脑筋的事出现,一个接一个的问题,人生就没有停下的时候,小问题不断出现。不过她今天看的书,她接受了人生就是不确定的,厉害的人就是不断创造确定性,在Ta的领域比别人多的确定性就能让自己脱颖而出,显示价值从而获得的比别人多的利益。正是这样的原因,因为从前修炼自己太少,使得她现在在人生道路上打怪起来困难重重,她似乎永远摆脱不了那种无力感,有种习</div>
                    </li>
                    <li><a href="/article/1835511542284644352.htm"
                           title="学点心理知识,呵护孩子健康" target="_blank">学点心理知识,呵护孩子健康</a>
                        <span class="text-muted">静候花开_7090</span>

                        <div>昨天听了华中师范大学教育管理学系副教授张玲老师的《哪里才是学生心理健康的最后庇护所,超越教育与技术的思考》的讲座。今天又重新学习了一遍,收获匪浅。张玲博士也注意到了当今社会上的孩子由于心理问题导致的自残、自杀及伤害他人等恶性事件。她向我们普及了一个重要的命题,她说心理健康的一些基本命题,我们与我们通常的一些教育命题是不同的,她还举了几个例子,让我们明白我们原来以为的健康并非心理学上的健康。比如如果</div>
                    </li>
                    <li><a href="/article/1835511163450912768.htm"
                           title="2021年12月19日,春蕾教育集团团建活动感受——黄晓丹" target="_blank">2021年12月19日,春蕾教育集团团建活动感受——黄晓丹</a>
                        <span class="text-muted">黄错错加油</span>

                        <div>感受:1.从陌生到熟悉的过程。游戏环节让我们在轻松的氛围中得到了锻炼,也增长了不少知识。2.游戏过程中,我们贡献的是个人力量,展现的是团队的力量。它磨合的往往不止是工作的熟悉,更是观念上契合度的贴近。3.这和工作是一样的道理。在各自的岗位上,每个人摆正自己的位置、各司其职充分发挥才能,并团结一致劲往一处使,才能实现最大的成功。新知:1.团队精神需要不断地创新。过去,人们把创新看作是冒风险,现在人们</div>
                    </li>
                    <li><a href="/article/1835511036317364224.htm"
                           title="Cell Insight | 单细胞测序技术又一新发现,可用于HIV-1和Mtb共感染个体诊断" target="_blank">Cell Insight | 单细胞测序技术又一新发现,可用于HIV-1和Mtb共感染个体诊断</a>
                        <span class="text-muted">尐尐呅</span>

                        <div>结核病是艾滋病合并其他疾病中导致患者死亡的主要原因。其中结核病由结核分枝杆菌(Mycobacteriumtuberculosis,Mtb)感染引起,获得性免疫缺陷综合症(艾滋病)由人免疫缺陷病毒(Humanimmunodeficiencyvirustype1,HIV-1)感染引起。国家感染性疾病临床医学研究中心/深圳市第三人民医院张国良团队携手深圳华大生命科学研究院吴靓团队,共同研究得出单细胞测序</div>
                    </li>
                    <li><a href="/article/1835511030260789248.htm"
                           title="c++ 的iostream 和 c++的stdio的区别和联系" target="_blank">c++ 的iostream 和 c++的stdio的区别和联系</a>
                        <span class="text-muted">黄卷青灯77</span>
<a class="tag" taget="_blank" href="/search/c%2B%2B/1.htm">c++</a><a class="tag" taget="_blank" href="/search/%E7%AE%97%E6%B3%95/1.htm">算法</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a><a class="tag" taget="_blank" href="/search/iostream/1.htm">iostream</a><a class="tag" taget="_blank" href="/search/stdio/1.htm">stdio</a>
                        <div>在C++中,iostream和C语言的stdio.h都是用于处理输入输出的库,但它们在设计、用法和功能上有许多不同。以下是两者的区别和联系:区别1.编程风格iostream(C++风格):C++标准库中的输入输出流类库,支持面向对象的输入输出操作。典型用法是cin(输入)和cout(输出),使用>操作符来处理数据。更加类型安全,支持用户自定义类型的输入输出。#includeintmain(){in</div>
                    </li>
                    <li><a href="/article/1835510909070569472.htm"
                           title="瑶池防线" target="_blank">瑶池防线</a>
                        <span class="text-muted">谜影梦蝶</span>

                        <div>冥华虽然逃过了影梦的军队,但他是一个忠臣,他选择上报战况。败给影梦后成逃兵,高层亡尔还活着,七重天失守......随便一条,即可处死冥华。冥华自然是知道以仙界高层的习性此信一发自己必死无疑,但他还选择上报实情,因为责任。同样此信送到仙宫后,知道此事的人,大多数人都认定冥华要完了,所以上到仙界高层,下到扫大街的,包括冥华自己,全都准备好迎接冥华之死。如果仙界现在还属于两方之争的话,冥华必死无疑。然而</div>
                    </li>
                    <li><a href="/article/1835510656011431936.htm"
                           title="爬山后遗症" target="_blank">爬山后遗症</a>
                        <span class="text-muted">璃绛</span>

                        <div>爬山,攀登,一步一步走向制高点,是一种挑战。成功抵达是一种无法言语的快乐,在山顶吹吹风,看看风景,这是从未有过的体验。然而,爬山一时爽,下山腿打颤,颠簸的路,一路向下走,腿部力量不够,走起来抖到不行,停不下来了!第二天必定腿疼,浑身酸痛,坐立难安!</div>
                    </li>
                                <li><a href="/article/118.htm"
                                       title="异常的核心类Throwable" target="_blank">异常的核心类Throwable</a>
                                    <span class="text-muted">无量</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/%E6%BA%90%E7%A0%81/1.htm">源码</a><a class="tag" taget="_blank" href="/search/%E5%BC%82%E5%B8%B8%E5%A4%84%E7%90%86/1.htm">异常处理</a><a class="tag" taget="_blank" href="/search/exception/1.htm">exception</a>
                                    <div>java异常的核心是Throwable,其他的如Error和Exception都是继承的这个类 里面有个核心参数是detailMessage,记录异常信息,getMessage核心方法,获取这个参数的值,我们可以自己定义自己的异常类,去继承这个Exception就可以了,方法基本上,用父类的构造方法就OK,所以这么看异常是不是很easy 
 
 
 
package com.natsu;


</div>
                                </li>
                                <li><a href="/article/245.htm"
                                       title="mongoDB 游标(cursor) 实现分页 迭代" target="_blank">mongoDB 游标(cursor) 实现分页 迭代</a>
                                    <span class="text-muted">开窍的石头</span>
<a class="tag" taget="_blank" href="/search/mongodb/1.htm">mongodb</a>
                                    <div>上篇中我们讲了mongoDB 中的查询函数,现在我们讲mongo中如何做分页查询 
 
&nbsp;&nbsp;&nbsp;&nbsp; 如何声明一个游标 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var mycursor = db.user.find({_id:{$lte:5}}); 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 迭代显示游标数</div>
                                </li>
                                <li><a href="/article/372.htm"
                                       title="MySQL数据库INNODB 表损坏修复处理过程" target="_blank">MySQL数据库INNODB 表损坏修复处理过程</a>
                                    <span class="text-muted">0624chenhong</span>
<a class="tag" taget="_blank" href="/search/tomcat/1.htm">tomcat</a><a class="tag" taget="_blank" href="/search/mysql/1.htm">mysql</a>
                                    <div>最近mysql数据库经常死掉,用命令net stop mysql命令也无法停掉,关闭Tomcat的时候,出现Waiting for N instance(s) to be deallocated 信息。查了下,大概就是程序没有对数据库连接释放,导致Connection泄露了。因为用的是开元集成的平台,内部程序也不可能一下子给改掉的,就验证一下咯。启动Tomcat,用户登录系统,用netstat -</div>
                                </li>
                                <li><a href="/article/499.htm"
                                       title="剖析如何与设计人员沟通" target="_blank">剖析如何与设计人员沟通</a>
                                    <span class="text-muted">不懂事的小屁孩</span>
<a class="tag" taget="_blank" href="/search/%E5%B7%A5%E4%BD%9C/1.htm">工作</a>
                                    <div>最近做图烦死了,不停的改图,改图……。烦,倒不是因为改,而是反反复复的改,人都会死。很多需求人员不知该如何与设计人员沟通,不明白如何使设计人员知道他所要的效果,结果只能是沟通变成了扯淡,改图变成了应付。 
 
那应该如何与设计人员沟通呢? 
 
我认为设计人员与需求人员先天就存在语言障碍。对一个合格的设计人员来说,整天玩的都是点、线、面、配色,哪种构图看起来协调;哪种配色看起来合理心里跟明镜似的,</div>
                                </li>
                                <li><a href="/article/626.htm"
                                       title="qq空间刷评论工具" target="_blank">qq空间刷评论工具</a>
                                    <span class="text-muted">换个号韩国红果果</span>
<a class="tag" taget="_blank" href="/search/JavaScript/1.htm">JavaScript</a>
                                    <div>

var a=document.getElementsByClassName('textinput');
					var b=[];
					for(var m=0;m&lt;a.length;m++){
						if(a[m].getAttribute('placeholder')!=null)
							b.push(a[m])
					}
					var l</div>
                                </li>
                                <li><a href="/article/753.htm"
                                       title="S2SH整合之session" target="_blank">S2SH整合之session</a>
                                    <span class="text-muted">灵静志远</span>
<a class="tag" taget="_blank" href="/search/spring/1.htm">spring</a><a class="tag" taget="_blank" href="/search/AOP/1.htm">AOP</a><a class="tag" taget="_blank" href="/search/struts/1.htm">struts</a><a class="tag" taget="_blank" href="/search/session/1.htm">session</a>
                                    <div>错误信息: 
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cartService': Scope 'session' is not active for the current thread; consider defining a scoped</div>
                                </li>
                                <li><a href="/article/880.htm"
                                       title="xmp标签" target="_blank">xmp标签</a>
                                    <span class="text-muted">a-john</span>
<a class="tag" taget="_blank" href="/search/%E6%A0%87%E7%AD%BE/1.htm">标签</a>
                                    <div>今天在处理数据的显示上遇到一个问题: 
var html = '&lt;li&gt;&lt;div class=&quot;pl-nr&quot;&gt;&lt;span class=&quot;user-name&quot;&gt;' + user
           + '&lt;/span&gt;' + text + '&lt;/div&gt;&lt;/li&gt;';
ulComme</div>
                                </li>
                                <li><a href="/article/1007.htm"
                                       title="Ajax的常用技巧(2)---实现Web页面中的级联菜单" target="_blank">Ajax的常用技巧(2)---实现Web页面中的级联菜单</a>
                                    <span class="text-muted">aijuans</span>
<a class="tag" taget="_blank" href="/search/Ajax/1.htm">Ajax</a>
                                    <div>在网络上显示数据,往往只显示数据中的一部分信息,如文章标题,产品名称等。如果浏览器要查看所有信息,只需点击相关链接即可。在web技术中,可以采用级联菜单完成上述操作。根据用户的选择,动态展开,并显示出对应选项子菜单的内容。 在传统的web实现方式中,一般是在页面初始化时动态获取到服务端数据库中对应的所有子菜单中的信息,放置到页面中对应的位置,然后再结合CSS层叠样式表动态控制对应子菜单的显示或者隐</div>
                                </li>
                                <li><a href="/article/1134.htm"
                                       title="天-安-门,好高" target="_blank">天-安-门,好高</a>
                                    <span class="text-muted">atongyeye</span>
<a class="tag" taget="_blank" href="/search/%E6%83%85%E6%84%9F/1.htm">情感</a>
                                    <div>&nbsp;&nbsp;&nbsp; 我是85后,北漂一族,之前房租1100,因为租房合同到期,再续,房租就要涨150。最近网上新闻,地铁也要涨价。算了一下,涨价之后,每次坐地铁由原来2块变成6块。仅坐地铁费用,一个月就要涨200。内心苦痛。 
 
&nbsp;&nbsp;&nbsp; 晚上躺在床上一个人想了很久,很久。 
&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; 我生在农</div>
                                </li>
                                <li><a href="/article/1261.htm"
                                       title="android 动画" target="_blank">android 动画</a>
                                    <span class="text-muted">百合不是茶</span>
<a class="tag" taget="_blank" href="/search/android/1.htm">android</a><a class="tag" taget="_blank" href="/search/%E9%80%8F%E6%98%8E%E5%BA%A6/1.htm">透明度</a><a class="tag" taget="_blank" href="/search/%E5%B9%B3%E7%A7%BB/1.htm">平移</a><a class="tag" taget="_blank" href="/search/%E7%BC%A9%E6%94%BE/1.htm">缩放</a><a class="tag" taget="_blank" href="/search/%E6%97%8B%E8%BD%AC/1.htm">旋转</a>
                                    <div>android的动画有两种 &nbsp;tween动画和Frame动画 
&nbsp; 
tween动画;,透明度,缩放,旋转,平移效果 
&nbsp; 
Animation &nbsp; 动画 
AlphaAnimation 渐变透明度 
RotateAnimation 画面旋转 
ScaleAnimation 渐变尺寸缩放 
TranslateAnimation 位置移动 
Animation</div>
                                </li>
                                <li><a href="/article/1388.htm"
                                       title="查看本机网络信息的cmd脚本" target="_blank">查看本机网络信息的cmd脚本</a>
                                    <span class="text-muted">bijian1013</span>
<a class="tag" taget="_blank" href="/search/cmd/1.htm">cmd</a>
                                    <div>@echo 您的用户名是:%USERDOMAIN%\%username%&gt;&quot;%userprofile%\网络参数.txt&quot;
@echo 您的机器名是:%COMPUTERNAME%&gt;&gt;&quot;%userprofile%\网络参数.txt&quot;
@echo ___________________&gt;&gt;&quot;%userprofile%\</div>
                                </li>
                                <li><a href="/article/1515.htm"
                                       title="plsql 清除登录过的用户" target="_blank">plsql 清除登录过的用户</a>
                                    <span class="text-muted">征客丶</span>
<a class="tag" taget="_blank" href="/search/plsql/1.htm">plsql</a>
                                    <div>tools---preferences----logon history---history&nbsp; 把你想要删除的删除 
 
 
-------------------------------------------------------------------- 
若有其他凝问或文中有错误,请及时向我指出, 
我好及时改正,同时也让我们一起进步。 
email : binary_spac</div>
                                </li>
                                <li><a href="/article/1642.htm"
                                       title="【Pig一】Pig入门" target="_blank">【Pig一】Pig入门</a>
                                    <span class="text-muted">bit1129</span>
<a class="tag" taget="_blank" href="/search/pig/1.htm">pig</a>
                                    <div>Pig安装 
1.下载pig 
&nbsp; 
wget http://mirror.bit.edu.cn/apache/pig/pig-0.14.0/pig-0.14.0.tar.gz 
&nbsp; 
2. 解压配置环境变量 
&nbsp; 
&nbsp;&nbsp; 如果Pig使用Map/Reduce模式,那么需要在环境变量中,配置HADOOP_HOME环境变量 
&nbsp; 
expor</div>
                                </li>
                                <li><a href="/article/1769.htm"
                                       title="Java 线程同步几种方式" target="_blank">Java 线程同步几种方式</a>
                                    <span class="text-muted">BlueSkator</span>
<a class="tag" taget="_blank" href="/search/volatile/1.htm">volatile</a><a class="tag" taget="_blank" href="/search/synchronized/1.htm">synchronized</a><a class="tag" taget="_blank" href="/search/ThredLocal/1.htm">ThredLocal</a><a class="tag" taget="_blank" href="/search/ReenTranLock/1.htm">ReenTranLock</a><a class="tag" taget="_blank" href="/search/Concurrent/1.htm">Concurrent</a>
                                    <div>为何要使用同步?&nbsp;  &nbsp; &nbsp; java允许多线程并发控制,当多个线程同时操作一个可共享的资源变量时(如数据的增删改查),&nbsp;   &nbsp; &nbsp; 将会导致数据不准确,相互之间产生冲突,因此加入同步锁以避免在该线程没有完成操作之前,被其他线程的调用,&nbsp;   &nbsp; &nbsp; 从而保证了该变量的唯一性和准确性。    1.同步方法&</div>
                                </li>
                                <li><a href="/article/1896.htm"
                                       title="StringUtils判断字符串是否为空的方法(转帖)" target="_blank">StringUtils判断字符串是否为空的方法(转帖)</a>
                                    <span class="text-muted">BreakingBad</span>
<a class="tag" taget="_blank" href="/search/null/1.htm">null</a><a class="tag" taget="_blank" href="/search/StringUtils/1.htm">StringUtils</a><a class="tag" taget="_blank" href="/search/%E2%80%9C%E2%80%9D/1.htm">“”</a>
                                    <div>转帖地址:http://www.cnblogs.com/shangxiaofei/p/4313111.html 
&nbsp; 
public&nbsp;static&nbsp;boolean&nbsp;isEmpty(String str)  &nbsp;   
  判断某字符串是否为空,为空的标准是 str== 
null&nbsp; 
或 str.length()== 
0   &nbsp;</div>
                                </li>
                                <li><a href="/article/2023.htm"
                                       title="编程之美-分层遍历二叉树" target="_blank">编程之美-分层遍历二叉树</a>
                                    <span class="text-muted">bylijinnan</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/1.htm">数据结构</a><a class="tag" taget="_blank" href="/search/%E7%AE%97%E6%B3%95/1.htm">算法</a><a class="tag" taget="_blank" href="/search/%E7%BC%96%E7%A8%8B%E4%B9%8B%E7%BE%8E/1.htm">编程之美</a>
                                    <div>

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class LevelTraverseBinaryTree {

    /**
     * 编程之美 分层遍历二叉树
     * 之前已经用队列实现过二叉树的层次遍历,但这次要求输出换行,因此要</div>
                                </li>
                                <li><a href="/article/2150.htm"
                                       title="jquery取值和ajax提交复习记录" target="_blank">jquery取值和ajax提交复习记录</a>
                                    <span class="text-muted">chengxuyuancsdn</span>
<a class="tag" taget="_blank" href="/search/jquery%E5%8F%96%E5%80%BC/1.htm">jquery取值</a><a class="tag" taget="_blank" href="/search/ajax%E6%8F%90%E4%BA%A4/1.htm">ajax提交</a>
                                    <div>
// 取值
	// alert($(&quot;input[name='username']&quot;).val());
	// alert($(&quot;input[name='password']&quot;).val());
	// alert($(&quot;input[name='sex']:checked&quot;).val());
	// alert($(&quot</div>
                                </li>
                                <li><a href="/article/2277.htm"
                                       title="推荐国产工作流引擎嵌入式公式语法解析器-IK Expression" target="_blank">推荐国产工作流引擎嵌入式公式语法解析器-IK Expression</a>
                                    <span class="text-muted">comsci</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/%E5%BA%94%E7%94%A8%E6%9C%8D%E5%8A%A1%E5%99%A8/1.htm">应用服务器</a><a class="tag" taget="_blank" href="/search/%E5%B7%A5%E4%BD%9C/1.htm">工作</a><a class="tag" taget="_blank" href="/search/Excel/1.htm">Excel</a><a class="tag" taget="_blank" href="/search/%E5%B5%8C%E5%85%A5%E5%BC%8F/1.htm">嵌入式</a>
                                    <div>这个开源软件包是国内的一位高手自行研制开发的,正如他所说的一样,我觉得它可以使一个工作流引擎上一个台阶。。。。。。欢迎大家使用,并提出意见和建议。。。 
----------转帖--------------------------------------------------- 
 IK Expression是一个开源的(OpenSource),可扩展的(Extensible),基于java语言</div>
                                </li>
                                <li><a href="/article/2404.htm"
                                       title="关于系统中使用多个PropertyPlaceholderConfigurer的配置及PropertyOverrideConfigurer" target="_blank">关于系统中使用多个PropertyPlaceholderConfigurer的配置及PropertyOverrideConfigurer</a>
                                    <span class="text-muted">daizj</span>
<a class="tag" taget="_blank" href="/search/spring/1.htm">spring</a>
                                    <div>1、PropertyPlaceholderConfigurer 
Spring中PropertyPlaceholderConfigurer这个类,它是用来解析Java Properties属性文件值,并提供在spring配置期间替换使用属性值。接下来让我们逐渐的深入其配置。 
 
基本的使用方法是:(1) 
 
&lt;bean id=&quot;propertyConfigurerForWZ&q</div>
                                </li>
                                <li><a href="/article/2531.htm"
                                       title="二叉树:二叉搜索树" target="_blank">二叉树:二叉搜索树</a>
                                    <span class="text-muted">dieslrae</span>
<a class="tag" taget="_blank" href="/search/%E4%BA%8C%E5%8F%89%E6%A0%91/1.htm">二叉树</a>
                                    <div>&nbsp;&nbsp;&nbsp; 所谓二叉树,就是一个节点最多只能有两个子节点,而二叉搜索树就是一个经典并简单的二叉树.规则是一个节点的左子节点一定比自己小,右子节点一定大于等于自己(当然也可以反过来).在树基本平衡的时候插入,搜索和删除速度都很快,时间复杂度为O(logN).但是,如果插入的是有序的数据,那效率就会变成O(N),在这个时候,树其实变成了一个链表. 
 
tree代码: 
 
</div>
                                </li>
                                <li><a href="/article/2658.htm"
                                       title="C语言字符串函数大全" target="_blank">C语言字符串函数大全</a>
                                    <span class="text-muted">dcj3sjt126com</span>
<a class="tag" taget="_blank" href="/search/c/1.htm">c</a><a class="tag" taget="_blank" href="/search/function/1.htm">function</a>
                                    <div>C语言字符串函数大全 
&nbsp; 
&nbsp; 
函数名: stpcpy 
功&nbsp;能: 拷贝一个字符串到另一个 
用&nbsp;法: char *stpcpy(char *destin, char *source); 
程序例: 
&nbsp; 
#include &lt;stdio.h&gt; 
#include &lt;string.h&gt; 
&nbsp; 
int main</div>
                                </li>
                                <li><a href="/article/2785.htm"
                                       title="友盟统计页面技巧" target="_blank">友盟统计页面技巧</a>
                                    <span class="text-muted">dcj3sjt126com</span>
<a class="tag" taget="_blank" href="/search/%E6%8A%80%E5%B7%A7/1.htm">技巧</a>
                                    <div>在基类调用就可以了, 基类ViewController示例代码 
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [MobClick beginLogPageView:[NSString stringWithFormat:@&quot;%@&quot;,self.class]];
</div>
                                </li>
                                <li><a href="/article/2912.htm"
                                       title="window下在同一台机器上安装多个版本jdk,修改环境变量不生效问题处理办法" target="_blank">window下在同一台机器上安装多个版本jdk,修改环境变量不生效问题处理办法</a>
                                    <span class="text-muted">flyvszhb</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/jdk/1.htm">jdk</a>
                                    <div>window下在同一台机器上安装多个版本jdk,修改环境变量不生效问题处理办法 
 
本机已经安装了jdk1.7,而比较早期的项目需要依赖jdk1.6,于是同时在本机安装了jdk1.6和jdk1.7. 
 安装jdk1.6前,执行java -version得到 
C:\Users\liuxiang2&gt;java -version 
java version &quot;1.7.0_21&quo</div>
                                </li>
                                <li><a href="/article/3039.htm"
                                       title="Java在创建子类对象的同时会不会创建父类对象" target="_blank">Java在创建子类对象的同时会不会创建父类对象</a>
                                    <span class="text-muted">happyqing</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/%E5%88%9B%E5%BB%BA/1.htm">创建</a><a class="tag" taget="_blank" href="/search/%E5%AD%90%E7%B1%BB%E5%AF%B9%E8%B1%A1/1.htm">子类对象</a><a class="tag" taget="_blank" href="/search/%E7%88%B6%E7%B1%BB%E5%AF%B9%E8%B1%A1/1.htm">父类对象</a>
                                    <div>&nbsp; 
1.在thingking in java 的第四版第六章中明确的说了,子类对象中封装了父类对象, 
&nbsp; 
2.&quot;When you create an object of the derived class, it contains within it a subobject of the base class. This subobject is the sam</div>
                                </li>
                                <li><a href="/article/3166.htm"
                                       title="跟我学spring3 目录贴及电子书下载" target="_blank">跟我学spring3 目录贴及电子书下载</a>
                                    <span class="text-muted">jinnianshilongnian</span>
<a class="tag" taget="_blank" href="/search/spring/1.htm">spring</a>
                                    <div>&nbsp; 
&nbsp; 一、《跟我学spring3》电子书下载地址: 
《跟我学spring3》 &nbsp;(1-7 和&nbsp;8-13)&nbsp;http://jinnianshilongnian.iteye.com/blog/pdf&nbsp;&nbsp; 
&nbsp; 
跟我学spring3系列 word原版 下载 
&nbsp; 
&nbsp; 二、
源代码下载  
最新依</div>
                                </li>
                                <li><a href="/article/3420.htm"
                                       title="第12章 Ajax(上)" target="_blank">第12章 Ajax(上)</a>
                                    <span class="text-muted">onestopweb</span>
<a class="tag" taget="_blank" href="/search/Ajax/1.htm">Ajax</a>
                                    <div>index.html 
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/</div>
                                </li>
                                <li><a href="/article/3547.htm"
                                       title="BI and EIM 4.0 at a glance" target="_blank">BI and EIM 4.0 at a glance</a>
                                    <span class="text-muted">blueoxygen</span>
<a class="tag" taget="_blank" href="/search/BO/1.htm">BO</a>
                                    <div>http://www.sap.com/corporate-en/press.epx?PressID=14787 
&nbsp; 
有机会研究下EIM家族的两个新产品~~~~ 
&nbsp; 
New features of the 4.0 releases of BI and EIM solutions include:  
 
  Real-time in-memory computing – </div>
                                </li>
                                <li><a href="/article/3674.htm"
                                       title="Java线程中yield与join方法的区别" target="_blank">Java线程中yield与join方法的区别</a>
                                    <span class="text-muted">tomcat_oracle</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a>
                                    <div>长期以来,多线程问题颇为受到面试官的青睐。虽然我个人认为我们当中很少有人能真正获得机会开发复杂的多线程应用(在过去的七年中,我得到了一个机会),但是理解多线程对增加你的信心很有用。之前,我讨论了一个wait()和sleep()方法区别的问题,这一次,我将会讨论join()和yield()方法的区别。坦白的说,实际上我并没有用过其中任何一个方法,所以,如果你感觉有不恰当的地方,请提出讨论。 
&nb</div>
                                </li>
                                <li><a href="/article/3801.htm"
                                       title="android Manifest.xml选项" target="_blank">android Manifest.xml选项</a>
                                    <span class="text-muted">阿尔萨斯</span>
<a class="tag" taget="_blank" href="/search/Manifest/1.htm">Manifest</a>
                                    <div>结构 
继承关系 
public final class Manifest extends Objectjava.lang.Objectandroid.Manifest 
内部类 
 
 
 class Manifest.permission权限 
 class Manifest.permission_group权限组 
 构造函数 
 
public Manifest () 详细  androi</div>
                                </li>
                                <li><a href="/article/3928.htm"
                                       title="Oracle实现类split函数的方" target="_blank">Oracle实现类split函数的方</a>
                                    <span class="text-muted">zhaoshijie</span>
<a class="tag" taget="_blank" href="/search/oracle/1.htm">oracle</a>
                                    <div>关键字:Oracle实现类split函数的方 
项目里需要保存结构数据,批量传到后他进行保存,为了减小数据量,子集拼装的格式,使用存储过程进行保存。保存的过程中需要对数据解析。但是oracle没有Java中split类似的函数。从网上找了一个,也补全了一下。 
 
CREATE OR REPLACE TYPE t_split_100 IS TABLE OF VARCHAR2(100); 
 
cr</div>
                                </li>
                </ul>
            </div>
        </div>
    </div>

<div>
    <div class="container">
        <div class="indexes">
            <strong>按字母分类:</strong>
            <a href="/tags/A/1.htm" target="_blank">A</a><a href="/tags/B/1.htm" target="_blank">B</a><a href="/tags/C/1.htm" target="_blank">C</a><a
                href="/tags/D/1.htm" target="_blank">D</a><a href="/tags/E/1.htm" target="_blank">E</a><a href="/tags/F/1.htm" target="_blank">F</a><a
                href="/tags/G/1.htm" target="_blank">G</a><a href="/tags/H/1.htm" target="_blank">H</a><a href="/tags/I/1.htm" target="_blank">I</a><a
                href="/tags/J/1.htm" target="_blank">J</a><a href="/tags/K/1.htm" target="_blank">K</a><a href="/tags/L/1.htm" target="_blank">L</a><a
                href="/tags/M/1.htm" target="_blank">M</a><a href="/tags/N/1.htm" target="_blank">N</a><a href="/tags/O/1.htm" target="_blank">O</a><a
                href="/tags/P/1.htm" target="_blank">P</a><a href="/tags/Q/1.htm" target="_blank">Q</a><a href="/tags/R/1.htm" target="_blank">R</a><a
                href="/tags/S/1.htm" target="_blank">S</a><a href="/tags/T/1.htm" target="_blank">T</a><a href="/tags/U/1.htm" target="_blank">U</a><a
                href="/tags/V/1.htm" target="_blank">V</a><a href="/tags/W/1.htm" target="_blank">W</a><a href="/tags/X/1.htm" target="_blank">X</a><a
                href="/tags/Y/1.htm" target="_blank">Y</a><a href="/tags/Z/1.htm" target="_blank">Z</a><a href="/tags/0/1.htm" target="_blank">其他</a>
        </div>
    </div>
</div>
<footer id="footer" class="mb30 mt30">
    <div class="container">
        <div class="footBglm">
            <a target="_blank" href="/">首页</a> -
            <a target="_blank" href="/custom/about.htm">关于我们</a> -
            <a target="_blank" href="/search/Java/1.htm">站内搜索</a> -
            <a target="_blank" href="/sitemap.txt">Sitemap</a> -
            <a target="_blank" href="/custom/delete.htm">侵权投诉</a>
        </div>
        <div class="copyright">版权所有 IT知识库 CopyRight © 2000-2050 E-COM-NET.COM , All Rights Reserved.
<!--            <a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">京ICP备09083238号</a><br>-->
        </div>
    </div>
</footer>
<!-- 代码高亮 -->
<script type="text/javascript" src="/static/syntaxhighlighter/scripts/shCore.js"></script>
<script type="text/javascript" src="/static/syntaxhighlighter/scripts/shLegacy.js"></script>
<script type="text/javascript" src="/static/syntaxhighlighter/scripts/shAutoloader.js"></script>
<link type="text/css" rel="stylesheet" href="/static/syntaxhighlighter/styles/shCoreDefault.css"/>
<script type="text/javascript" src="/static/syntaxhighlighter/src/my_start_1.js"></script>





</body>

</html>