A star algorithm

Hi Everyone,
How to implement A star algorithm into the 15 x 15 maze? Herewith attached with "queue stacked search" which workable on 15 x 15 maze. Now, I want to change to another search algorithm which is called A star algorithm. Any clear instruction regarding on this method? 
Many thnaks. 
Attachments:
Version 1 - Copy.zip ‏59 KB

Hi Christinalau,
now that is the third thread on solving a maze, all you change is the kind of solving algorithm. Again: please stick to your original thread!
Here and here!
For all interested persons: we're discussing Christinas school homework here...
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome

Similar Messages

  • Simple Tree searching algorithm

    Hi folks,
    I just need someone to give me a little hint about the A* (a star) algorithm to be applied on n-nary tree. I guess some of u reading this may have good algorithms concept and can help me. I am stuck for 3 nights :(
    Thanks a lot in advance for caring to read.

    Hi folks,
    I just need someone to give me a little hint about
    the A* (a star) algorithm to be applied on n-nary
    tree. I guess some of u reading this may have good
    algorithms concept and can help me. I am stuck for 3
    nights :(
    Thanks a lot in advance for caring to read.No one knows how your tree (API) looks like. So no one knows how your A* algorithm can make a guess as to where to go to find the finish-node. Post what you have been trying here.
    When posting code, please use code tags: http://forum.java.sun.com/help.jspa?sec=formatting

  • Help Using Path Finding Code

    Hi all.
    I found some open source code which implements the A Star algorithm to achieve path finding for the purpose of navigating something in a game (although it could really be used for anything). Problem is, I can't get it to work. I've e-mailed the author but no reply yet so I was hoping someone could shed some light on my situation.
    The code is meant to find a path on a 2 dimensional grid filled with obstacles using the following methods:
    PathFinder star = new PathFinder(grid);
    Path p = star.findShortest(startRow,startCol,goalRow,goalCol);
    I've made a simple Test class with a small 2D array but when I compile the code I recieve the error:
    Incompatible types.
    Found: int.
    Required: Test.Path
    on Path p = star.findShortest(1,1,2,2);
    I don't understand this error at all. The findShortest method takes 4 integers and I'm passing it 4 integers! Any ideas what this error means?
    Here's my Test class:
    import java.util.*;
    import javax.swing.plaf.basic.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    import javax.swing.filechooser.*;
    import java.util.Random;
    public class Test
            public static void main(String args[])
                    Test test = new Test();
                    test.run();
           public final static class Path
                    /** 2 for down, 0 is up, 1 is right and 3 is left */
                    public int giveMove() {
                        if (size() < 2)
                            return -1;
                        Position last = (Position)positions.get(size() - 1);
                        Position forlast = (Position)positions.get(size() - 2);
                        if (forlast.col - last.col == 1)
                            return 2; //down
                        else if (forlast.col - last.col == -1)
                            return 0; //up
                        else if (forlast.row - last.row == 1)
                            return 1;//right
                        else if (forlast.row - last.row == -1)
                            return 3; //left
                        return -1;
                    /** list of positions */
                    public List positions;
                    public int getCost() { return positions.size() - 1; }
                    public int size() { return positions.size(); }
                    public void add(Object o) { positions.add(o); }
                    /** add (r,c) to the path */
                    public void add(int r, int c) {
                        positions.add(new Position(r,c));
                    /** get first position */
                    public Position head() { return (Position) positions.get(0); }
                    public Path(ArrayList positions) { this.positions = positions; }
                    public Path(Position initial) {
                        positions = new ArrayList(1);
                        positions.add(initial);
                    public Path(int cap) { positions = new ArrayList(cap); }
                    public void set(Position front, Path old) {
                        positions.add(front);
                        Iterator i = old.positions.iterator();
                        while (i.hasNext())
                            positions.add(i.next());
            /** position on the grid */
           public static final  class Position
                    public int row, col;
                    public Position(int row, int col) {
                        this.row = row; this.col = col;
            public void run()
                    System.out.println("Test");
                    PathFinder star = new PathFinder(grid);
                    for(int counter = 0; counter < grid.length; counter++)
                            for (int j=0; j < grid[counter].length; j++)
                                    grid[counter][j] = 0;
                    Path p = star.findShortest(1, 1, 2, 2);
         private static int[][] grid = new int[2][2];    
    } Here's the PathFinder class I downloaded:
    import java.util.*;
    import javax.swing.plaf.basic.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    import javax.swing.filechooser.*;
    import java.util.Random;
    public final class PathFinder {
        /** the map grid to look on */
        private final int [][] grid;
        /** keep distances to each position here */
        private final int [][] distances;
        /** is gridposition (r, c) empty (empty is -1) ? */
        private boolean isEmpty(int r, int c) {
            return grid[r][c] == -1 ;
        /** pathfinder for grid */
        public PathFinder(int[][] grid) {
            this.grid = grid;
            this.distances = new int [grid.length][grid.length];
        /** clear distances */
        private void clear() {
            for (int i = 0 ; i < distances.length ; i++)
                for (int j = 0 ; j < distances.length ; j++)
    distances[i][j] = Integer.MAX_VALUE;
    /** position on the grid */
    public final static class Position {
    public int row, col;
    public Position(int row, int col) {
    this.row = row; this.col = col;
    /** path from start to a certain position */
    public final static class Path {
    /** 2 for down, 0 is up, 1 is right and 3 is left */
    public int giveMove() {
    if (size() < 2)
    return -1;
    Position last = (Position)positions.get(size() - 1);
    Position forlast = (Position)positions.get(size() - 2);
    if (forlast.col - last.col == 1)
    return 2; //down
    else if (forlast.col - last.col == -1)
    return 0; //up
    else if (forlast.row - last.row == 1)
    return 1;//right
    else if (forlast.row - last.row == -1)
    return 3; //left
    return -1;
    /** list of positions */
    public List positions;
    public int getCost() { return positions.size() - 1; }
    public int size() { return positions.size(); }
    public void add(Object o) { positions.add(o); }
    /** add (r,c) to the path */
    public void add(int r, int c) {
    positions.add(new Position(r,c));
    /** get first position */
    public Position head() { return (Position) positions.get(0); }
    public Path(ArrayList positions) { this.positions = positions; }
    public Path(Position initial) {
    positions = new ArrayList(1);
    positions.add(initial);
    public Path(int cap) { positions = new ArrayList(cap); }
    public void set(Position front, Path old) {
    positions.add(front);
    Iterator i = old.positions.iterator();
    while (i.hasNext())
    positions.add(i.next());
    /** gives the move to take for the shortest path from startRow to startCol
    * 0 up, 1 right, 2 down, 3 left
    * -1 if no move possible
    public final int findShortest
    (int startRow, int startCol, int goalRow, int goalCol) {
    clear();
    Position initial = new Position(startRow, startCol);
    //LinkedList list = new LinkedList();
    Position goal = new Position(goalRow, goalCol);
    BinaireHoop list = new BinaireHoop(200, new Path(goal), goal);
    list.add(new Path(initial));
    Position [] successors = new Position[4];
    int trie = 0;
    for ( ; ! list.isEmpty() && trie < 10000 ; trie++) {
    Path first = (Path) list.remove();
    Position firstPos = first.head();
    int r = firstPos.row; int c = firstPos.col;
    if (r == goalRow && c == goalCol) {  //goal found !             
    return first.giveMove();
    } else {
    int successorsCount = 0;
    if (isEmpty(r-1,c)) {
    successors[successorsCount++]
    = new Position(r-1, c);
    if (isEmpty(r+1,c)) {
    successors[successorsCount++]
    = new Position(r+1, c);
    if (isEmpty(r,c-1)) {
    successors[successorsCount++]
    = new Position(r, c-1);
    if (isEmpty(r,c+1)) {
    successors[successorsCount++]
    = new Position(r, c+1);
    while (successorsCount-- > 0) {
    Position succ = successors[successorsCount];
    int newPathCost = first.getCost() + 1;
    //add newPath if shorter than other path to this position
    if (distances[succ.row][succ.col] > newPathCost) { //shorter
    distances[succ.row][succ.col] = newPathCost;
    Path newPath = new Path(newPathCost + 1);
    newPath.set(succ, first);
    //add path to binary heap
    list.add(newPath);
    } // else longer: discard
    return -1;
    There's also a BinaireHoop class which the PathFinder class uses. I'll post that code if anyone thinks it's relevant but the error appears to be soley on my implementation. The Path and Position and just small subclass which for the sake of quickness I just placed into my Test class too instead of into a new class to themselves.
    Any thoughts appreciated! I would really like to get this working =)
    Thanks.

    Thanks for your reply. Doh, totally missed that one =)
    Anyway, I got the code working but it's still very buggy. I think this must just be a problem with the PathFinder class I downloaded.
    I create a 2D array
          int[][] array = {       
                                  {-1, -1, -1, -1, -1, -1, -1, -1},          
                                  {-1, -1, -1, -1, -1, -1, -1, -1},
                                  {-1, -1, -1, -1, -1, -1, -1, -1},
                                  {-1, -1, -1, -1, -1, -1, -1, -1},
                                  {-1, -1, -1, -1, -1, -1, -1, -1},
                                  {-1, -1, -1, -1, -1, -1, -1, -1},
                                  {-1, -1, -1, -1, -1, -1, -1, -1},
                                  {-1, -1, -1, -1, -1, -1, -1, -1}
                          };and choose starting and goal coordinates
    int p = star.findShortest(1, 1, 2, 2);The PathFinder will generate the coordinates to move to (I just stuck it all in a loop and updated the starting coordinates as appropriate to lead me to the goal). This is great!
    However, there seem to be a lot of bugs when I introduce "occupied squares". Basically, -1 in the array means that that square is empty whereas anything else means its full and the path finder should, in theory, generate a path around these obstacles. This isn't working correctly though.
    Sometimes a path wil be found around the obstacle, sometimes the path will go straight through it, and many times it just throws an array index out of bounds exception error!
    Anyone got any ideas? Or does anyone have any examples of a working path finder? =)
    Cheers

  • Solution: A-Star Path Finding Algorithm (games)

    Hello everyone. I have developed several A-Star implementations for games, if you come across anyone with questions relating to path finding, please direct them to [email protected]

    I'll also be directing several rich Nigerians who need your help, too, if that is OK.

  • How to use the path generated by A star to guide the robot to move?

    I now know how to use A star path planning on Voronoi and I can run this program successfully.\  
    however, my problem now is how i can use the path data (generated by the A* path planning algorithm) to guide the robot to drive along this path?   well, i suppose i can get a series of dots (denoted by x and y coordinates) from the path, and use these dots to guide the robot ?  
    can anyone please help?  
     thank you very much
    Solved!
    Go to Solution.

    Ravens Fan wrote:
    You can't.
    My post above will point everyone to the other post so that we don't have people trying to assist you in two different places without knowledge of the other thread.
    thank you 

  • Tile-based map and A-star help?

    I am working on a tower defense type game. A while ago I posted asking about maze logic and was kindly directed towards A-star pathfinding. It is perfect. I understand the concept and it makes sense. Now the problem I am having is how to do the tile-based map? I'm having a hard time wrapping my head around it. I just want to do a straight square map comprised of squares. I realize a 2D Array would probably be the best way just such as:
    int[][] map = new int[100][100]
    where there would be 100 x 100 tiles. I can then populate the array with numbers ie 0 = walkable, 1 = unwalkable. I can have my A* algorithm return the set of tiles to move to.
    My problem is that I don't want my game to be in pixels and I'm having a hard time understanding how to make the game appear tile based and large enough to be playable? ie. 1 tile = 30x30 pixels. If we are looking at it in terms of model and view, I understand the model part, but I am having a hard time translating to the view? How do I create a tile based view so that the user can only place towers on a tile(the mouse click location could be any point inside the tile)? Also, how would I keep the enemy units moving smoothly between tiles and not just jumping to the center of each tile?
    I got some great advice last time and any more advice or points in a good direction would be greatly appreciated.

    The reason to distribute your maze into nodes (tiles) is that pathfinding is slow, so you want to eliminate any notion of screen dimensions (pixels, inches, etc.) from A*. For all purposes, your maze is 100x100 pixels; any given object can choose between 100 horizontal and 100 vertical values.
    how would I keep the enemy units moving smoothly between tiles and not just jumping to the center of each tile?Although your units may only have 100x100 nodes to consider, you can still animate them walking between each adjacent node on the path. Remember that the pathfinding (per tier) will occur before anything actually moves.
    Still, this could look funny with only 100 nodes per axis. Units should use the shortest path that’s visible to them, and turning several degrees at each node will look choppy. So. I list three potential solutions here:
    &bull; Increase the number of nodes (the “accuracy”). Speed may be an issue.
    &bull; Use path smoothing algorithm. I haven’t seen your circumstance, but I would generally recommend this.
    &bull; Use multi-tiered/hierarchical pathfinding. This is probably more complex to implement.
    Note that although the second and third options are distinct, they may coincide (some smoothing algorithms use multiple tiers). Googling for ‘pathfinding smoothing’ returned many results; this one in particular looked useful: [Toward More Realistic Pathfinding|http://www.gamasutra.com/features/20010314/pinter_01.htm]
    How do I create a tile based view so that the user can only place towers on a tile(the mouse click location could be any point inside the tile)?If objects can be placed at arbitrary points, then A* needs to deem nodes impassable (your array’s 1) based on the objects placed in them. You have to be careful here and decide whether entire nodes should be ignored based on tower’s partial presence; for instance:
    |====|====|====|====|====|
    |====|====|====|===+|+++=|
    |====|====|====|===+|+++=|
    |====|====|====|====|====|
    |0~0=|====|====|====|====|pixels: = ; node dividers: | (and line breaks for vertical) ; tower: +
    The tower only covers ¼ of the node at (3, 3); should you eliminate it? Five solutions are obvious:
    • Ignore any node with any chunk of a tower in it.
    • Ignore any node entirely covered by a tower.
    • Ignore any node whose center is covered by a tower. This won’t work with multi-tiered pathfinding.
    • Ignore any node that has a tower covering any point the units are required to pass through. This will work with multi-tiered pathfinding.
    • Using multi-tiered pathfinding, consider only consider the sub-nodes that aren’t covered by a tower.
    I realize a 2D Array would probably be the best way just such as
    int[][] map = new int[100][100]
    For starters, if only want two values—passable and impassible—then a boolean would be better. But I would recommend against this. I’d bet you could write some OO code specific to your situation. You might want to use terrain costs, where nodes exist that A* would prefer over others.
    I hope I answered some of your questions. Let me know if you have more—or if I didn’t.
    Good luck.
    —Douglas

  • Will star transformation be scalable?

    This is rather an algorithmic question
    I happen to read a post about a real-world problem.
    http://groups.google.com/group/comp.databases.oracle.server/browse_thread/thread/0db61c4fab79769a?hl=en
    Simple back envelope analysis shows that star transformation would be very expensive in terms of storage:
    The fact table F has 750 million rows, a dimensional table D has 70k rows. Suppose I have a bitmap join index between F and D to support star transformation.
    How large would the bitmap index be?
    70k values, each need a bitmap vector of 750M bits. The bitmap size would be 70k x (750M/8) bytes=6.6kGb. Is that too large?
    Or, I miss something? If partition can help, how?
    I guess my general questions is that if the dimension table's cardinality is in the order of thousands, what solution would Oracle provide? Thanks.
    T.K.

    Thanks for the link. However, I do not see any metrics mentioning about bitmap compression degree.
    I agree that 6.6kG join bitmap index is not in the compression form. However, in general to what degree can a bitmap be compressed? In this particular example, suppose it can be compressed by a ratio of 100. Then, we still need 6.6kG/100=66G for the bitmap join index. Decompressing it on the fly also take a lot of CPUs cycles. Adding more CPU cores would not benefit since most cores share the same L2 cache. (cache misses would be a bottleneck)
    Are there any benchmark results or documents discussing bitmap compression effect and showing the practical side of a reasonable large db benefiting from Star transformation like this example?
    thanks,
    T.k.

  • Multiple star or snow flake schema for universe

    Hi,
    I would like to know following things
    1. Can we use more than one star or snow flake schema for an universe? and how to do this?
    2. Using multiple shemas for one universe is it good practice or not?
    Regards,
    Manjunath

    Manjunath,
    This is exactly where BusinessObjects excels.
    When dealing with multiple fact tables, you use contexts.
    Contexts are very simple to understand and you must take your time to do so if you are going to successfully develop universes based on more than one fact table. No matter what universe you build, the rule for contexts is always the same; there are no different circumstances based on, say, industry.
    Each context starts with a base table, typically a fact table, where all its joins are at the many end of the relationship. The joins are then followed out through the joined tables up other joins where they in turn are at the many end, as in a snowflake schema.
    For example, consider the very basic schema below:
    D1 -< D2 -< F1 >- D3 -< F2 >- D4
    There are two tables that only have many joins attached to them - F1 and F2.
    Starting with F1, I can move to D2. I can also move from there to D1. In the other direction, I can move from F1 to D3. However, I cannot move from D3 to F2 because the join cardinalities are in the wrong direction. So, I've found all the joins that belong in the first context. They are D1-D2, D2-F1 and F1-D3. By the same process, I will get to the second context containing joins D3-F2 and F2-D4.
    It doesn't work well with many-to-many joins, but you really shouldn't be facing these in a well-designed multi-star.
    As for one-to-one joins, set the cardinality as one-to-many in the direction that you know the relationship should be in for the ownership to work out correctly..
    The process that I've described above is essentially how the Detect Contexts algorithm works.
    The only remaining thing for you to read up on is the SQL parameters but essentially you need ot be able to select multiple contexts and generate multiple sql statements for each context. Otherwise, what's the point in defining them?!!
    Hope that clears it up for you.
    Regards,
    Mark

  • PrEl 9. Do star ratings affect Instant movie results?

    Hi everybody.
    Do the star ratings that you assign to your videos in the Elements Organizer have any weigh or effect on the clips that are chosen by Adobe when you do an Instant Movie project?
    I fist did a (rather typical) zoo movie, where the elefant turned out to be the main subject of the instant movie rather than my family. I guess the elefant clip was better iluminated, steady, etc and had the right smart tags so that it was shown a lot of times.
    In another project for one of my kid's birthday I assigned star ratings to the clips that I liked before I ran the auto analyzer and created an instant movie. In the end I had more of the clips I liked in my instant movie.
    I don't know if this was mere coincidence or if star rating had anything to do with it. I couldn't find any reference to star ratings in the premiere elements help where it talks about instant movie projects.
    What has been your experience on this?
    Thanks,
    Asdrubal.

    Thank you Steve.
    I know the star rating doesn't affect the clips, I just wondered if they had any effect on the Instant Movie algorithms.
    Like you say they must be only for personal reference, as there is no mention of them in the instant movie help files.

  • Lightroom Mobile - Color and Stars rating

    In order to be able to use LR mobile as an pre-selection tool we urgently need stars & color rating options for Lightroom Mobile. Can't believe it was left out while designing v1.0. This is just another data field. Apart from the opportunities to retouch the photos which are pretty useless atm, I can wait for them to evolve, the rating stuff is essential to really fall into workflow. So dear LR mobile team, efforts in adding stars and color ratings are really much appreciated. Well and smart collection would be nice as well!
    To add some praise. I love the idea and I appreciate that the sync is running pretty good and also the app itself is running smoothly even though the adjustment interface is far apart from being an eye candy. But I would say it's aligned to be an working tool instead of being a feast for the eyes.
    So I'm looking forward and hoping more rating features appearing on the horizon soon.
    Cheers,
    LX

    Thanks Tom for your kind reply!! I'm also Product Manager in Product Development for a big company and being in charge of realiziing convergent use cases across the entire device spectrum and therefore totally agree with your approach to get into things. My complaint wasn't meant to be ungrateful it was just the sight of an user which has set up use-cases and workflows to efficiently get the job (even it's a hobby) done. So hope you got it right. I've experienced Lightroom and Photoshop over the past few years a really great tools, but from my point of view, Adobe sometimes is focused to much on being amazing algorithm developers and less customer workflow supporters. I'm really spending a lot of time with my photography partner (also a reallife Product Manager) discussing what could have been from a simple workflows point of view. I'm pretty sure there is quite a lot of wishes our there. From obviousness to edge cases, but we always came to certain points where presumed little efforts would make a huge difference.
    To come to an end. I'm looking forward to see star and color rating (and probably support for smart galleries) hopefully very soon. Thank you guys for the move to bring Lightroom to the tablet!
    If you and the team are interested on more precise feedback on LR-Mob and probably Lightroom workflows I would be delighted to provide you with.
    So if you are interested, just pick me up, I've dropped you a linkedin request.
    All the best from overseas,
    Alex B.

  • Navigation algorithm suggestion

    Maps 3.06 (and earlier) has difficulties in distinguishing roads from each other, when the roads are very close to each other. This leads to onfusion when a highway flies over a minor road, or when a highway is just 10 meters away from a minor road in parallel. This brought me to the following idea for improvement in the navigation algorithm:
    Let the navigator assume on which road it is by the SPEED. E.g. when I drive 120 km/h, the navigator may assume that I am on the highway and not on the small road which has a speed limit of 80 km/h.
    I am aware that this will not lead to 100% correct determinations, but it will be much better than the current system which seems to make a random choice between the roads (if the roads are near to each other).
    Does this make sense?
    The dedicated Mio navigator in my car has the same problem, albeit to a smaller extend because its GPS unit is more accurate.
    Cheers, Herman

    Post this in Ovi Maps Beta Labs discussions for the dev team to consider.
    If you find my post helpful please click the green star on the left under the avatar. Thanks.

  • How do I add a widget to give a review or star rating for a book at the end of a book in iBooks Author?

    How do I add a widget to give a review or star rating for a book at the end of a book in iBooks Author? You know, how you buy books on iBooks and when you're finished reading it, there's a place where you can give a rating or review right there on the very last page?

    Just supply a link that says 'Review This Book' - use http://itunes.apple.com/linkmaker/ to generate one.

  • Getting Error while decrypt a file using Blowfish algorithm

    I am using blowfish algorithm for encrypt and decrypt my file. this is my code for encrypting decrypting .
    while i am running program i am getting an Exception
    Exception in thread "main" javax.crypto.BadPaddingException: Given final block not properly padded
    at com.sun.crypto.provider.SunJCE_h.b(DashoA6275)
    at com.sun.crypto.provider.SunJCE_h.b(DashoA6275)
    at com.sun.crypto.provider.BlowfishCipher.engineDoFinal(DashoA6275)
    at javax.crypto.Cipher.doFinal(DashoA12275)
    at Blowfishexe.main(Blowfishexe.java:65)
    import java.security.*;
    import javax.crypto.*;
    import javax.crypto.spec.*;
    import java.io.*;
    import org.bouncycastle.crypto.CryptoException;
    import org.bouncycastle.crypto.KeyGenerationParameters;
    import org.bouncycastle.crypto.engines.DESedeEngine;
    import org.bouncycastle.crypto.generators.DESedeKeyGenerator;
    import org.bouncycastle.crypto.modes.CBCBlockCipher;
    import org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher;
    import org.bouncycastle.crypto.params.DESedeParameters;
    import org.bouncycastle.crypto.params.KeyParameter;
    import org.bouncycastle.util.encoders.Hex;
    public class Blowfishexe {
    public static void main(String[] args) throws Exception {
    KeyGenerator kgen = KeyGenerator.getInstance("Blowfish");
              kgen.init(128);
              String keyfile="C:\\Encryption\\BlowfishKey.dat";
    SecretKey skey = kgen.generateKey();
    byte[] raw = skey.getEncoded();
    SecretKeySpec skeySpec = new SecretKeySpec(raw, "Blowfish");
              System.out.println("key"+raw);
                   byte[] keyBytes = skey.getEncoded();
                   byte[] keyhex = Hex.encode(keyBytes);
                   BufferedOutputStream keystream =
    new BufferedOutputStream(new FileOutputStream(keyfile));
                        keystream.write(keyhex, 0, keyhex.length);
    keystream.flush();
    keystream.close();
    Cipher cipher = Cipher.getInstance("Blowfish");
    cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
              System.out.println("secretKey"+skeySpec);
    FileOutputStream fos=new FileOutputStream("C:\\Encryption\\credit11.txt");
              BufferedReader br=new BufferedReader(new FileReader("C:\\Encryption\\credit.txt"));
              String text=null;
              byte[] plainText=null;
              byte[] cipherText=null;
              while((text=br.readLine())!=null)
              System.out.println(text);
              plainText = text.getBytes();
              cipherText = cipher.doFinal(plainText);
              fos.write(cipherText);
              br.close();
              fos.close();
              cipher.init(Cipher.DECRYPT_MODE, skeySpec);
              FileOutputStream fos1=new FileOutputStream("C:\\Encryption\\BlowfishOutput.txt");
              BufferedReader br1=new BufferedReader(new FileReader("C:\\Encryption\\credit11.txt"));
              String text1=null;
              /*while((text1=br1.readLine())!=null)
                   System.out.println("text is"+text1);
                   plainText=text1.getBytes("UTF8");
                   cipherText=cipher.doFinal(plainText);
                   fos1.write(cipherText);
              br1.close();
              fos1.close();
    //byte[] encrypted = cipher.doFinal("This is just an example".getBytes());
              //System.out.println("encrypted value"+encrypted);*/
    Any one pls tell me how to slove my problem
    thanks in advance

    hi
    i got the solution. its working now
    but blowfish key ranges from 56 to448
    while i am writing the code as
    KeyGenerator keyGenerator = KeyGenerator.getInstance("Blowfish");
    keyGenerator.init(448);
    this code is generating the key upto 448 bits
    but coming to encoding or decode section key length is not accepting
    cipher.init(Cipher.ENCRYPT_MODE, key);
    Exception in thread "main" java.security.InvalidKeyException: Illegal key size or default parameters
    at javax.crypto.Cipher.a(DashoA12275)
    at javax.crypto.Cipher.a(DashoA12275)
    at javax.crypto.Cipher.a(DashoA12275)
    at javax.crypto.Cipher.init(DashoA12275)
    at javax.crypto.Cipher.init(DashoA12275)
    at Blowfish1.main(Blowfish1.java:46)
    i am getting this error
    what is the solution for this type of exception.
    thank you

  • SHA2 Algorithm support in Adobe Acrobat 9

    Hello,
    1) Does Acrobat 9 supports SHA2 Hash algorithms while signing PDF file?
    2) As per my understanding PDF is signed using below approach
        Step 1. Take the PDF contents
        Step 2. Calculate the Hash of the content
        Step 3. Then sign(Encrypt) the hash. (here again we calculate the hash)
      So we are hashing the content twice.
      If I use SHA1 algorithm in Step2 and SHA2 algorithm in Step3, Adobe 9 is able to verify the signature. But if i use SHA2 algorithm in Step1 & Step 2
      Adobe 9 is saying "Content altered....."
      Why so?
    Please help.
    Thanks in advance
    Priyanka

    SHA2 was only added in Acrobat 9.1.  Also, the Microsoft Base CSP is needed for SHA2 support - Base CSP is included in Vista and Windows 7, but in XP it needs to be downloaded as a seperate addon.
    How are you setting the values in your SecurityHandler?  Off the top of my head, I believe in order to use SHA2 to hash the content (your "Step 2") you need to use AES-256 as your encryption algorithm which required a different cryptVersion be set in your SecurityHandler structure.

  • Why when using Adobe Bridge,  I apply a star rating,  the rating does not show up in Photoshop Elements? [tags]

    Why when using Adobe Bridge,  I apply a star rating,   the rating does not show up in Photoshop Elements.  I use Elements as my organizer and Bridge to view as it is much more user friendly.  Anyone any solutions??

    Most likely you have set the wrong file as the external editor. You don't want the obvious one; that's just a link to the welcome screen. Go back and choose this one, which is hidden away inside the folder Support Files:

Maybe you are looking for

  • A new name for a company

    Hello all I'm switching to a new name for my company. The website content will stay the same. My question is this. If I go to "site Definition" and change the old name & the root folder over to my new name will it delete any of my pages or do somethi

  • Is this a bug of NIO???

    I am using nio to write a network server. I use following code to close a SocketChannel: Socket s = sc.socket();           if (s != null) {                try {                     s.close();                } catch (IOException e) {                  

  • Financial Reporting Studio - Subtotals at each change in Member

    I am using "bottom of Hierarchy" to pull all potential members but would like to subtotal at each change in member. I've tried auto calculation but that only works for the total. I know I could also make each member a line item and have a subtotal th

  • IPhoto 9.5 using latitude and longitude

    I am extremely frustrated with iPhoto's location function. I'm trying to geotag photos using latitude and longitude. iPhoto insists on trying to convert lat/long to an address that is inaccurate. When I try to reposition the pin point in the map it f

  • Reloading iLife on my Mac Mini

    I do not know how to reload iLife on my Mac Mini. I do not have iLife '06. I have the previous version. It came installed on my mini but has since "cracked out" after some "housekeeping" on my mac (my husband may have thrown some important stuff away